Generating Random Numbers
Generating Random Numbers
Generating Random
Numbers
+
THE GENERATION OF PSEUDO-
RANDOM NUMBERS
Agenda
generating random number uniformly distributed
+
Why important in General
Numerical analysis,
random numbers are used in the solution of complicated integrals.
In computer programming,
random numbers make a good source of data for testing the effectiveness
of computer algorithms.
Cryptography
Random numbers also play an important role in cryptography.
+
Why it is important in Simulation
random numbers are used in order to introduce randomness in the model.
In Machine interference Simulation model we assumed constant for most of
TIMES (repair time, operational time) that is not the case in general
If we are able to observe the operational/repair times of a machine over a
reasonably long period, we will find that they are typically characterized by a
theoretical or an empirical probability distribution.
THEREFORE we should randomly fallow a theoretical or an empirical
probability distribution
Hence we need uniformly distributed random numbers, to produce random
variates or stochastic variates
+
Recap.. Uniform distribution
each member of the family, all intervals of the same length on the
distribution's support are equally probable. FIGURE SHOWS THE
PDF
+
Pseudo-Random Numbers
there is no such a thing as a single random number
To generate
physical phenomenon (true random)
Unpredictable non reproducible, natural software hardware
Thermal noise of a diode, radioactive decay
ideal for cryptography, not good for simulation WHY?
TO mathematical algorithms
produce numbers in a deterministic fashion.
Start value Seed
these numbers appear to be random since they pass a number of statistical
tests designed to test various properties of random numbers
Therefore they are referred to as pseudo-random numbers.
DEBUG
on demand generation no need to store
uniformly distributed in the space [0, 1]
Example Set of
A set of such values is: a = 314, 159, 269, c = 453, 806, 245, and m = 2^32
(for a 32 bit machine).
+
A question ??????
General congruential
One of the good examples for this type of generator uses the second
congruential generator to shuffle the output of the first congruential
generator
+
Tausworthe generators
ai are binary
combining two previously calculated elements that lag behind the current element
utilizing an algebraic operation O.
GOODNESS OF FIT
runs test, and
chi-square test for goodness of fit.
+
Frequency test (Monobit test)
In a true random sequence, the number of 1’s and 0’s should be about
the same
Sobs=0.6324.
Step 6
If P-value1 or P-value2 < 0.01 then we reject the null hypothesis that the
sequence is random, else we accept the null hypothesis that the sequence is
random. (0.01 is significance level)
As in the frequency test, if the overlapping bit combinations are not uniformly
distributed, ΔS 2 and Δ2 S 2 become large that causes the P-values to be small.
+
Example Serial Test
e = 0011011101, with n=10, and k=3
Frequency
C1 0 0 0 f1 0
Step 1 C2 0 0 1 f2 1
Append the k-1=2 bits e1 = 001101110100. C3 0 1 0 f3 1
C4 0 1 1 f4 2
appending the first k-2=1 e2=00110111010 C5 1 0 0 f5 1
C6 1 0 1 f6 2
k-3=0 e3 = e = 0011011101. C7 1 1 0 f7 2
C8 1 1 1 f8 0
Step 2 frequency calculation
For the 3-bit blocks we use e1
For the 2- bit blocks we use e2 Frequency
For the 1-bit blocks we use e=e3 C1 0 0 f1 1
Frequency C2 0 1 f2 3
C1 0 f1 4
C2 1 f2 6 C3 1 0 f3 3
C4 1 1 f4 3
+
Since both P-value1 and P-value2 are greater than 0.01, this sequence
passes the serial test.
+
Auto Corelations
The runs test can be used to test the assumption that the pseudo-
random numbers are independent of each other. We start with a
sequence of pseudo-random numbers in [0,1]. We then look for
unbroken subsequences of numbers, where the numbers within each
subsequence are monotonically increasing. Such a subsequence is
called a run up, and it may be as long as one number.
+
Chi-square test for goodness of fit
http://en.wikipedia.org/wiki/Uniform_distribution_(continuous)