COMP3014J Week4
COMP3014J Week4
Week-4
1
People vector created by macrovector - www.freepik.com
Dr. Nima Afraz [email protected] Performance of(School
http://nima.ie/ Computer
of Computer
System Science, UniversityWeek-4
College Dublin) 2 / 28
Random Number
Why?
Simulation must generate random values for variables in a specified
random distribution, such as normal, exponential distribution
How? Two steps:
random number generation: generate a sequence of uniform
Full-period random numbers in [0,1]
random variate generation: transform a uniform random sequence
to produce a sequence with the desired distribution
▶ A random variate generation algorithm is any program that halts and
exits with a real number x. This x is called a random variate.
CDF:
Function f is deterministic
Given the seed, we can tell with a probability of 1 what the numbers
in the sequence would be.
Reproducibility (often desirable)
Be able to repeat a simulation experiment
They pass statistical tests for randomness
Statistics Test
Contains no recognisable patterns or regularities
▶ Dice roll
Efficiently computable
Since simulations typically require several thousand random numbers
in each run, the processor time required to generate these numbers
should be small.
Period should be large
A small period may cause the random-number sequence to recycle,
resulting in a repeated event sequence. This may limit the useful
length of simulation runs.
Successive values should be
The correlation between successive numbers should be small.
Correlation, if significant, indicates dependence
Independent
Uniformly distributed
xn = (axn−1 + b) mod M
Examples
xn = an mod m
For example, 31: the primitive roots are 3, 11, 12, 13, 17, 21, 22, 24
Dr. Nima Afraz [email protected] Performance of(School
http://nima.ie/ Computer
of Computer
System Science, UniversityWeek-4
College Dublin) 22 / 28
Randomness Test