Exercise 5

Consider one-dimensional random walks with initial positions x = 0 (at t = 0), where a step Δx = ±xstep (for a given xstep) is realized with probabilities w+ = w- = ½ , during a time interval tstep (for a given tstep).

We want to determine the time evolution p(a,b,t) of the probability of the position x to be in a given interval [a, b].

Write the program to generate Nsim walks, where each walk consists of Nstep steps, and determine the above-mentioned time evolution, given (in the program) in terms of the two tables time[i] and phi[i]. The time values time[i] should be chosen as

i × Ntime × tstep .


The time distribution should coincide (approximately) with an integral over pDE, so compute as well the latter, using the table fun[i]. Print time[i], phi[i], fun[i] to standard output. So when executing the program, we should get three columns, representing time[i], phi[i], fun[i].

Use Nsim = 100000, Nstep = 2400, Ntime = 160, xstep = 0.025, tstep = 0.025, a = 3, b = 5.

For a possible graphical representation of the results, see here.

In case of problems in understanding basic notions of the programming langage C: see C tutorial

The solution of this exercise can be found here