Exercise 1

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). 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. One should choose appropriate values for xmin and xmax. The x-distribution should coincide (approximately) with pDE, so compute as well pDE(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 = -15, xmax=15. Compute the diffusion coefficient D, needed to compute pDE .

Try also the case Nsub = 7, xmin = -15, xmax=15. Why doesn't this work too well? Count for this case the number of even integers which fall into each interval, which allows to understand the problem.

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