PseudoRandom Numbers: Linear Congruential Generators As digital computers are deterministic machines - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

PseudoRandom Numbers: Linear Congruential Generators As digital computers are deterministic machines

Description:

In addition to various 'Run Tests' and non-parametric tests, the following are useful. ... the length of the simulation run. Expected number in the system ... – PowerPoint PPT presentation

Number of Views:236
Avg rating:3.0/5.0
Slides: 7
Provided by: brianmc58
Category:

less

Transcript and Presenter's Notes

Title: PseudoRandom Numbers: Linear Congruential Generators As digital computers are deterministic machines


1
Pseudo-Random Numbers Linear Congruential
GeneratorsAs digital computers are
deterministic machines, they are incapable of
generating random numbers. Instead they generate
large cycles of pseudo-random numbers (i.e.)
numbers which will pass most of the statistical
tests for randomness. However, if the program is
rerun on a subsequent day the exact same stream
of numbers will be produced. To overcome this
problem, since the chain of numbers is very
large, a starting seed which uses the current
date and I.D. number of the user can be used to
enter the chain at different points every time
the program is run. a pseudo-random number
generator is said to be full cycle if it leaves
no gaps in the range of numbers it
generates.Form X0 a given seed Xi1
( a Xi c ) mod mExample Xi1 7 Xi mod
11 -gt 1, 7, 5, 2, 3, 10, 4, 6, 9, 8, (1) Xi1
6 Xi mod 11 -gt 1, 6, 3, 7, 9, 10, 5, 8, 4, 2,
(1)Example IMSL Xi1 16807 Xi
mod (231 - 1) a prime modulus SIMSCRIPT
Xi1 6303600167 Xi mod (231 - 1) RANDU
Xi1 65539 Xi mod (231 ) Lemma.
Xi1 a Xi mod m, with m prime, is full cycle
if m divides ai - 1 for i m-1, but for no
smaller i Xi1 ( a Xi c ) mod m is full
cycle if c and m are relatively prime and if p
divides m then p divides a - 1,
if 4 divides m then 4 divides a - 1
2
Tests for RandomnessIn addition to various Run
Tests and non-parametric tests, the following
are useful.Chi-Square TestWe partition the M
random numbers generated into n classes and
calculate the test statistic S ( Oj - Ej )2 /
Ej c2M-n-1 distribution for M large, min Ej
gt 4 and Ej 4 M0.4.Kolmogorov Smirniv
Test.Order the observations so that X1 X2
Xn and calculate over i 1, 2, , n Kn
Ö n Max i / n - F ( Xi ) K-n Ö n Max F
( Xi ) - (i - 1) / nIf Kn or K-n are either
too big or too small, reject H0 Distribution
is F at the relevant confidence
interval.k-Dimensional Spectral Tests 1.
Regard the numbers as points on 0, 1
uniformly distributed 2. Regard the pairs ( Xi,
Xi1 ) as points in 0, 12 uniformly
distributed 3. Regard the triplets ( Xi, Xi1,
Xi2 ) as points on 0, 13 ..Lemma. The
sequences of size n from the generator Xi1 a
Xi mod m fall on at most (n! m)1/n parallel
hyperplanes.The Spectral Value of a generator
is the maximum distance between the hyperplanes.
A generator with a small spectral value is
desirable.
3
Example. The diagrams show that Xi1 7 Xi
mod 11 has a spectral value of 3.479, while
that of Xi1 6 Xi mod 11 is
4.919.Newspaper Boy ProblemThis is a seminal
example, which shows how a
(Historical Data)forecasting filter can use
historical data to Index Demand Freq.
optimise parameter settings in nonlinear models.
i Xi fi S fi F ( Xi
)The newspaper boy buys papers at 40p, sells
1 10 10 10
0.10them at 50p and gets 20p back on unsold
copies 2 30 25 35
0.35at the end of the day. His corporate
strategy is 3 70 45
80 0.80to buy 90 of the demand that
occurred on the 4 100 15
95 0.95previous day. 5
130 5 100 1.00 Day 0
1 2 3 4 5
6 Random - 0.25 0.60
0.80 0.55 0.90 0.45 Buy - 63
20 47 63 43
81 Demand 70 22 52 70
48 90 39 Sell - 22
20 47 48 43
39 Return - 41 0 0
15 0 42 Profit (p)
- -600 200 470 180 430
-450 Cumulative (p) - -600 -400
70 250 680 230
3.479
4.919
4
Nonuniform Random Numbers - SearchIn simulation
models we typically disregard the first 10,000
iterations to allow the system reach an
equilibrium and then monitor the simulation over
the next 100,000 iterations.Binary search is
quite an efficient algorithm for finding the
simulation value relative to a look-up key. In
simulation models as this look-up facility will
be used a large number of times, it is important
that the most efficient algorithm is used. Bucket
search is the most efficient algorithm known for
searching tables.Suppose X1 lt X2 lt lt
XnPlace m equally spaced buckets on 0, 1, with
m a power of 2 and n m 3 n.Let pi Min
j F (Xj ) gt (i - 1) / m qi Min j F (Xj )
³ i / m Algorithm Generate the uniform 0, 1
random number U Search pk pk1, , qk for j
with F (Xj - 1) lt U F (Xj ) Return j -
1 Interpolate for the exact value X F(Xj) -
UXj-1 U - F(Xj-1)Xj F(Xj) -
F(Xj-1)Example Newspaper BoySuppose U 0.96
and m 8, so we search 4, , 5 for j F( X4)
lt 0.96 F (X5 )Return 4 and so X 106, by
interpolation.
5
Generating Nonuniform Random NumbersLemma. U
uniform 0, 1 ltgt Prob U a a Lemma.
F(X) increasing gt F(X) uniform 0, 1 Prob
F(X) a Prob X F-1 (a ) F F-1 (a )
a .Lemma. F-1(U) has the distribution
function F. Prob F-1 (U) t Prob U F(
t) F( t). Exponential. F( x) 1 - exp ( -
l x) , for x ³ 0, so F-1 (U) - ln ( 1 - U
) / l has an exponential distribution with rate
l . For convenience, tables of - ln ( 1 - U )
have been published. This distribution is the
kernel of simulation systems for modelling
queues.Cauchy This is the Student t1
distribution has median m, scale s and has no
mean or higher moments. Using this distribution
will result in the simulation model crashing.
The sequence in which it crashes can be used to
debug the simulation model. Later a proper
random number generator can be substituted. F(
x) 1 / p Tan -1 (x - m ) / s 1 / 2 F-1
( U) s Tan p ( U - 1/2 ) mNormal The
Box-Muller formulae generate approximate n (0, 1)
pairs Yi Cos ( 2 p Ui1 ) Ö -2 ln (Ui)
Zi Sin ( 2 p Ui1 ) Ö -2 ln (Ui)
1
U
1
a
1
1
F (x)
a
X
F-1 ( a )
6
Illustration of M M 1The diagram
illustrates the dual nature of queuing
statistics. T is the length of the simulation
run. Expected number in the system Shaded
Area / T.This corresponds to numerical
integration (accumulation) and requires careful
computer coding.Expected waiting time in the
system S Service Time Ends i - S Arrival
Time i Number of Customers nThis is a tally
operation, requiring the use of threeregisters
and is easy to implement.Computer simulation
languages, such as SIMSCRIPT, are a direct
implementation of these ideas. The one caveat
that needs to be added at this time, is that
writing good simulation models requires
considerable skill. In particular, unless the
variance terms are controlled, each simulation
run will result in wildly differing results.
State
No. in the System
3
T
E1
E2
E3
E4
E5
E6
3
0
1
2
4
5
6
Stage
Write a Comment
User Comments (0)
About PowerShow.com