
12 Monte Carlo Methods
Section 12.2: Random Number Generation
12.1. Generate uniform random numbers using software such as MATLAB, either using the linear
congruential generator or the program’s built-in random number generator. Plot the average value and
the standard deviation and compare them with the theoretical values for the uniform distribution.
Solution: Consider uniform numbers between 0 and 1. The theoretical mean and the standard deviation
are
µ =
1
0
xdx =
1
2
σ =
E {X
2
} − µ
2
=
4
1
0
x
2
dx −
1
2
2
= 0.2887.
Matlab’s rand.m function can generates a square matrix whose elements are random numbers. Following
script can generate the average value and the ...