Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use python to complete this Develop code to calculate in a 1d, 2d, 3d ran

ID: 3828281 • Letter: P

Question

Please use python to complete this

Develop code to calculate in a 1d, 2d, 3d random walks what is the distribution of time it takes for a particle to return back to zero for the first time. In other words, launch a random walk, stop it when the particle is back at zero (and be careful that it may never come back to zero, so account for this in your code), record time to zero. Do it many times and histogram the distribution. Notice the long ta in this distribution. Estimate what is the fraction of particles in different dimensions that never return back to the origin.

Explanation / Answer

from collections import Counter def get_term_frequency_in_file(source_file_path): wordcount = {} with open(source_file_path) as f: for line in f: line = line.lower().translate(None, string.punctuation) this_wordcount = Counter(line.split()) wordcount = add_merge_two_dict(wordcount, this_wordcount) return wordcount def add_merge_two_dict(x, y): return { k: x.get(k, 0) + y.get(k, 0) for k in set(x) | set(y) }