Given by Geoffrey C. Fox at CPS615 Basic Simulation Track for Computational Science on Fall Semester 95. Foils prepared 21 October 1995
Outside Index
Summary of Material
This CPS615 Module has an overview of Random Numbers and statistics at the level needed for clear discussion of Monte Carlo Integration |
It starts with basic properties of Random Numbers and extensions to multiple random variables and concept of independencs |
Derivation of non-uniform probability distribution is illustrated with Gaussian distribution |
We discuss computer generation of random variables for both sequential and parallel machines |
Outside Index Summary of Material
Geoffrey Fox |
NPAC |
Syracuse University |
111 College Place |
Syracuse NY 13244-4100 |
This CPS615 Module has an overview of Random Numbers and statistics at the level needed for clear discussion of Monte Carlo Integration |
It starts with basic properties of Random Numbers and extensions to multiple random variables and concept of independencs |
Derivation of non-uniform probability distribution is illustrated with Gaussian distribution |
We discuss computer generation of random variables for both sequential and parallel machines |
Everything can be derived from uniform random numbers in the range [0,1] = [r1, r2] |
Such random numbers are supplied by all serious scientific computers |
You can derive other distributions by variations of the following dodge which uses functions of a uniform or other known random distribution |
Remember mean of x is |
m is the mean, s is standard deviation |
"A Small Miracle" asserts that: |
If x1 x2 are uniformly distributed in [0,1] -- Then:
|
are Gaussianly distributed |
with mean = 0 and standard deviation = 1 |
while g1 and g2 are independent. |
Proof: Consider |
Integral: |
with g1 g2 going to Polar coordinates (r=radius, angle) |
and then transform to x1and x2 by |
(-2lnx1)1/2 = radius i.e. x1=exp(-r2/2) and |
2px2 = angle |
Intuitively, random numbers come from large physical systems whose size implies that different atoms act (decay) independently, e.g. observed time of decay of radioactive particle is a random number. |
Computers generate "pseudo random numbers"
|
xn+1 = (axn + c) mod m
|
See Knuth1 or Numerical Recipes2. |
1) Knuth, D.E., "Seminumerical Algorithms "Vol. 2, The Art of Computer Programming, Addison-Wesley Publishing Co.1969 |
2) Flannery,B.P., Press,W.H., Teukolsky,S.A., Vetterling,W.T., "Numerical Recipes in Fortran", The Art of Scientific Computing, Cambridge University Press 1992 |
Take the choice: |
m = 231 |
a = 1103515245 |
c = 12345 |
Implemented in C as (64 bit) |
newran = [a*oldran+c] & MASK |
floatran = newran/2147483648.0 |
oldran = newran |
floatran is uniformly distributed in [0,1] |
MASK has lower 31 bits = 1and all higher bits = 0 |
This intuitively says that lower order bits of a complex multiplication are "essentially" random |
You do not need to "understand" this. |
It is useful to check random number generator. |
Is xn+i independent of xn for different values of i= 1...? |
Also, note one must specify a "seed" = initial value x0 |
Then "random numbers" follow deterministically. |
x0 => x1 => x2 ...... |
Set seed (x0) from "Time of Day" |
Save seed so can rerun program.. |
An old Turbo Pascal Random Number Generator |
There are correlations .... |
More than 1,000,000 random numbers generated by Turbo-Pascal v3.0 and plotted as (xn,xn+1) pairs. |
Parallel random numbers are somewhat nontrivial. |
If have N processors, must have numbers independent within and between processors. |
See "Solving Problems on Concurrent Processors"
|
One strategy is to have one stream and make every N'th number go to a given processor. This can be done very efficiently as described in reference above. |
The result is:
|
Let xi be independent random numbers -- each with same distribution p(x). |
Distribution of x: p(x) anything (reasonable) |
Distribution of y: Gaussian but more importantly sharply peaked with width of peak -> 0 |
x and z are random variables with distributions - one has n copies of each |
y = S (zi=f(xi))/n is a random variable with a distribution ,even though we only have one value for y we can calculate properties of this distribution including most importantly the expected error in y |
This is most importantly applied in case f(x)=x and the above allows one to calculate error in basic central limit theorem application to y = S xii/n |
We review the different Integration Formulae |
Gaussian Integration |
Unequally spaced prescribed points |
Monte Carlo Integration |