Download presentation
Presentation is loading. Please wait.
Published byAshlynn Riley Modified over 9 years ago
1
Pseudo-random-number generators
2
Random numbers: the numbers generated by a stochastic process They are indispensible in any simulations based on radom sampling. The „true” random numbers are obtained by hardware devices (the so-called random-noise generators). These are, however, expensive. However, by performing a sequence of algebraic operations on integer numbers, a sequence of numbers can be generated which are effectively random. Such numbers are referred to as pseudo- random numbers.
3
Linear Congruential Generators (LCG) A sequence of pseudo-random numbers generated by LCG has a period m, if and only if: (a)c and m do not have common divisors. (b)b=a-1 is a multiplicity of any primary number p, which is a divisor of m. (c)b is a multiplicity of 4, if m also is a multiplicity of 4.
4
xixi x i+1 m=7, a=3 The sequences of consecutive t pseudo-random numbers generated by MLCG form a regular t- dimensional lattice. Example: t=2
5
m=97, a=29m=97, a=23 uiui u i+1 uiui The uniform feature of the pseudo-random number distribution depends very strongly on the ratio of m do a
6
Conditions for uniformity d t – the largest distance between lattice nodes Almost uniform distribution Significant deviation from the uniform distribution Lower limits on the distance
7
Spectral test
8
Appropriate values of the modules m and multipliers a for transferable generators with the 32- and 16-bit arithmetics 32 bit16 bit mama 21474836473937332749162 21474835634001432363157 21474833994069232143160 21474828114154632119172 21474828014202431727146 21474837394574231657142
9
uiui u i+1 m=32749, a=162
10
Multiplicative linear congruent generators (MLCG) Faster than te LCG generators but have a shorter period the number 0 cannot be obtained. The rank of an MLCG generator: the smallest that satisfies the equation a mod m = 1 The maximum period of a pseudo-random numbers generated by an MLCG is equal to the rank of that generator.
11
A portable version of MLCG designed by Wichmann, Hill, and L’Ecuyer K=IX/IQ IX=IA*(IX-K*IQ)-K*IR IF (IX.LT.0) IX=IX+M M=2147483563 IA=40014 IQ=53668 IR=12211
12
The VRND generator (based on the XOR operation) and RANDOMV (LCG). The ran0, ran1 (shortest execution time), ran2 (optimally randomized numbers), ran3 (MLCG) generators from Numerical Recipes Generation of real pseudo-random numbers Best results are obtained if several MLCG generators are combined. IEOR: bitwise exclusive OR A10110101 B11011101 IEOR(A,B)01101000
13
Generation of non-uniformly distributed random numbers 1.By transformation of the uniform distribution. 2.By the von Neumann „hit-and-miss” method.
14
Uniform distribution transformation Let x be a random number normally distributed in [0,1] A random number with distribution given by g(y) can then be computed from the inverse of the distribuand G(y) at x provided that G has the inverse:
15
Transormation of a random number x with a uniform distribution to random number y with distribund G(y) for continuous (a) and discrete (b) distributions.
16
Example: random number with exponential distribution
17
An example of exponential distribution generation for various sampling sizes.
18
The von Neumann „hit-and-miss” method x f(x) x min x max f min f max Rejected points Accepted points
19
An efficient algorithm to generate normal distribution 1.Generate two pseudo-random numbers u 1 i u 2 from a uniform distribution in [0,1]. Compute v 1 =2u 1 -1 i v 2 =2u 2 -1. 2.Compute s=v 1 2 +v 2 2. 3.If s>=1, go back to 1. 4.Compute These numbers are drawn from a normal distrubition with 0 mean and unit variance. To generate a multidimensional normal distribution, the Cholesky transfomation of the variance-covariance matrix is carried out first and then variables i =(L T (x-a)) i are generated from normal distributions with zero mean and unit variance. These are subsequently transformed to the original variable space by applying the inverse transformation. The gaussdev.f program from Numerical Recipes.gaussdev.f
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.