Exercise 4

Consider one-dimensional random walks with initial positions x = 0 (at t = 0), where a step Δx is realized according to the law

  Δx Probability
 +xstep  0.45
 -xstep  0.35
 0  0.20

(for given xstep), during a time interval tstep (for a given tstep). Be x the position after Nstep steps (which corresponds to the time t = tstep × Nstep.

Write the program to generate Nsim walks, where each walk consists of Nstep steps, and determine the x-distribution (the distribution of the x-values after Nstep steps), given (in the program) in terms of the two tables xmi[i] and phi[i], as explained here. The x-distribution should coincide (approximately) with pFP (we have a non-zero shift), so compute as well pFP(xmi[i]), using the table fun[i] for the latter. Print xmi[i], phi[i], fun[i] to standard output. So when executing the program, we should get three columns, representing xmi[i], phi[i], fun[i].

Use Nsim = 10000, Nstep = 100, xstep = 1, tstep = 1, Nsub = 15, xmin = -5, xmax=25. Compute the diffusion coefficient D and the shift velocity v, needed to compute pFP .

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