0% found this document useful (0 votes)
54 views18 pages

Random Numbers & Generation

This document discusses random number generation which is important for simulation. It describes the desired properties of random number generators including independence, speed, and long cycles. It then explains several methods for generating random numbers, like the mid-square method, Fibonacci method, and linear congruential method. Finally, it outlines several tests that can evaluate random number generators like frequency, runs, and autocorrelation tests.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views18 pages

Random Numbers & Generation

This document discusses random number generation which is important for simulation. It describes the desired properties of random number generators including independence, speed, and long cycles. It then explains several methods for generating random numbers, like the mid-square method, Fibonacci method, and linear congruential method. Finally, it outlines several tests that can evaluate random number generators like frequency, runs, and autocorrelation tests.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

Random Numbers

&
Their Generation

Submitted By:
Karandeep Singh
C08323
C.S.E. , 6TH Sem.
Overview
Importance of random number generation
Desiderata for a random number generator
(RNG)
Methods for generating random numbers
Methods for testing random number generators
Additional considerations
Summary

C08323
Importance of
Random Number Generation
In simulation, we need them to model stochastic
variation (if not, why are we simulating?)
We really need pseudo-random numbers, not
random numbers, so that:
– We can verify and validate more easily
– We can test system alternatives under equal
conditions

C08323
Desiderata for a RNG
1. It should generate independent values
faithfully mimicking U[0,1]
2. The RNG should be fast
3. The RNG should need little storage
4. The RNG should be portable
5. The RNG should have a long cycle
6. The random variates should be
replicable and available “by stream”
C08323
The Mid-Square Method
Startwith a 4-digit number, the seed
Square it to obtain an 8-digit number,
with zero fill on left if needed
Middle 4 digits of those 8 are next
random number
Let’s try it with 7182 as seed

C08323
The Fibonacci Method
Zi = (Zi-1 + Zi-2) mod m
This type of generator usually has a
period exceeding m
At first, it was praised in the literature
Oops – consecutive output values
satisfying the inequality Zi-2 <Zi<Zi-1 are
impossible1
C08323
That inequality should be satisfied 1/6 of
The Linear Congruential
Method
Xi+1 = (aXi + c) mod m
X0 is the seed
– a is the constant multiplier
– c is the increment
– m is the modulus
If c≠0, “mixed congruential method”
If c=0, “multiplicative congruential
method” C08323
Longest (Best) Cycle
To obtain the longest possible cycle:
1.Set m = 2b (consider computer word size)
2.Set c ≠ 0 (mixed congruential method)
3.Ensure GCD(c,m) = 1
4.Ensure a ≡ 1 mod 4

C08323
What If Longer Cycle
Needed?
On most computers, these methods
achieve a cycle of length ≈ 109
Work in the 1980s by Pierre L’Ecuyer, a
world expert in RNGs, produced
combined linear congruential generators
with cycles of length ≈ 1018
His more recent work has produced
generators with cycles of length ≈ 1057C08323
Tausworthe Generators
These generators operate directly with
bits to form random numbers
Essentially independent of computer’s
word size
Huge cycles (e.g., > 10156 achieved)
Empirical evidence for their superiority
lacking
GPSS/H abandoned use of these, C08323

returning to LCGs to facilitate stream


Tests for Random Numbers
1.Frequency test – are the numbers
evenly sprinkled on [0,1]?
 Procedures available:
– Kolmogorov-Smirnov
– Anderson-Darling
– χ2
 This is a test for uniformity; the next
four tests examine independence
C08323
Tests for Random Numbers
2.Runs tests
 Runs up and runs down – there should
be neither too few nor too many
 Runs above and below the mean –
there should be neither too few nor too
many
 Lengths of runs – should be variable
C08323
Tests for Random Numbers
3.Tests for autocorrelation
 Various lags may be examined (e.g., is
every 5th number high [or low])?
 If successive pairs (Ri, Ri+1) are
plotted in the unit square, do they fall
on lines?
 If successive triplets (Ri, Ri+1, Ri+2)
are plotted in the unit cube, do they C08323
fall
Tests for Random Numbers
4.Tests for gaps
 What are the intervals between
successive occurrences of the same
digit?
 These intervals should follow the
negative binomial distribution

C08323
Tests for Random Numbers
5. The Poker test
 For example, in random numbers
containing 4 decimal digits, how often
do the following appear? –
– “no pair,” e.g., 0.3785
– “one pair,” e.g., 0.2278, 0.2782,
0.2728,0.7822
– “two pairs,” e.g., 0.2323, 0.3322,
0.2332 C08323
Distributions Other than
U[0,1]
 Basic RNGs are U[0,1]
 To obtain other distributions from
U[0,1], use:
1. Inverse Transform technique
2. Direct Transformation (for normal or
lognormal)
3. Convolution
C08323
4. Acceptance-Rejection
Antithetic Variates
 Two RNGs are antithetic if
corresponding numbers (e.g., the 984th
number from each RNG) add to 1. That
is, if one random number is high, its
counterpart is low, and vice versa.
 Excellent for variance reduction among
consecutive pairs of replications.
C08323
Summary
 RNGs are a specialized field of study
within simulation research
 Understanding the basic principles of
RNGs, and knowing the method used
by the RNG in the software you’re
using, is far superior to blind trust in a
“black box”
C08323

You might also like