Exercise 3
Consider one-dimensional random walks with decay, with initial positions x = 0 (at t = 0), where a step Δx = ±xstep (for a given xstep) is realized with probabilities w+ = w- = (1-mu*tstep)/2 , during a time interval tstep (for a given tstep). The decay probability is 1 - w+ - w- = mu*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 pDED (solution of the diffusion equation with decay, see lecture), so compute as well pDED(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, mu = 0.005. Compute the diffusion coefficient D, needed to compute pDED .
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