Exercise 8
We want to generate random numbers according to the law
f(x) = (2*π)^(-1/2) × exp(-x2/2) for x ∈ ]-∞,∞[ ,
referred to as "normal distribution". One should use the method of generation via polar coordinates.
We want to determine (as usual) the x-distribution, given (in the program) in terms of the two tables xmi[i] and phi[i], as explained here. The x-distribution should coincide with the function f(x), so we should find φi = f(xi) .
Write the corresponding program to generate Nsim = 10000 random numbers as explained above, and determine the x-distribution, i.e. determine xmi[i] and phi[i]. In addition also compute f(xi), using the table fun[i] in the program. 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].
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