













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














Purpose & Overview
Frequency test
Autocorrelation test.
Generation of Pseudo-Random Numbers
“Pseudo”, because generating numbers using a knownmethod removes the potential for true randomness.
Goal: To produce a sequence of numbers in [
0,
] that
simulates, or imitates, the ideal properties of random numbers(RN).
Important considerations in RN routines:
Fast
Portable to different computers
Have sufficiently long cycle
Replicable
Closely approximate the ideal statistical properties of uniformityand independence.
Techniques for Generating RandomNumbers
Linear Congruential Method (LCM).
Combined Linear Congruential Generators (CLCG).
Example
[LCM]
Use
X
0
= 27
,
a = 17
,
c = 43
, and
m = 100
.
The
X
i
and
R
i
values are:
1
= (17*27+43) mod 100 = 2,
1
2
= (17*2+32) mod 100 = 77,
2
3
= (17*77+32) mod 100 = 52,
3
Characteristics of a Good Generator
[LCM]
Maximum Density
Such that he values assumed by
, i = 1,2,…i
, leave no large
gaps on
Problem: Instead of continuous, each
i^
is discrete
Solution: a very large integer for modulus m
Approximation appears to be of little consequence
Maximum Period
To achieve maximum density and avoid cycling.
Achieve by: proper choice of
a
c
m
, and
0
Most digital computers use a binary representation ofnumbers
Speed and efficiency are aided by a modulus,
m
, to be (or close
to) a power of
Combined Linear Congruential GeneratorsTheorem: If
are any independent discrete-
valued random variable, and
is uniformly
distributed on
then
i ,
i ,
i , k
i ,
[0,
m
1
−
2]
i
i ,^
j
j^
=
1 k ∑
1
is uniformly distributed on
1
11
Combined Linear Congruential Generators
[Techniques]
Suggested form:
The maximum possible period is:
X
i
=
W
i ,
(
−
j −
1
X
i ,^
j
2 k ∑
⎛ ⎜⎜⎝
⎞ ⎟⎟⎠
mod (
m
1
−
i^
i
1
i
1
1
i
1
2
1
−
k
k
m
m
m
The coefficient:
Performs the subtraction
X
i,1-
Tests for Random Numbers
Two categories:
Testing for uniformity:
0
i^
1
i^
Failure to reject the null hypothesis, H
0
, means that evidence of
non-uniformity has not been detected.
Testing for independence:
0
i^
~ independently
1
i^
~ independently
Failure to reject the null hypothesis, H
0
, means that evidence of
dependence has not been detected.
Level of significance
α,
the probability of rejecting H
0
when it
is true:
α
= P(reject H
0
|H
0
is true)
/ /
Tests for Random Numbers
When to use these tests:
If a well-known simulation languages or random-numbergenerators is used, it is probably unnecessary to test
If the generator is not explicitly known or documented, e.g.,spreadsheet programs, symbolic/numerical calculators, testsshould be applied to many sample numbers.
Types of tests:
Theoretical tests: evaluate the choices of m, a, and c withoutactually generating any numbers
Empirical tests: applied to actual sequences of numbersproduced. Our emphasis.
[
Frequency Test]
Compares the continuous cdf,
F(x)
, of the uniform
distribution with the empirical cdf,
S
N
(x),
of the
N
sample
observations.
We know:
If the sample from the RN generator is
1
2
N
, then the
empirical cdf,
N
(x)
is:
Based on the statistic:
D = max| F(x) - S
N
(x)|
Sampling distribution of
is known
(a function of
N
, tabulated in
Table A.8.)
A more powerful test, recommended.
1
0
,
)
(
≤
≤
=
x
x
x
F
N
x R R R x S
n
N
≤
=
are
which
,...,
,
of
number
)
(
2
1
17
[
Frequency Test]
Example: Suppose
5
generated numbers are
0.44, 0.81, 0.14,
0.05, 0.
.
Step 1: Step 2: Step 3:
D = max(D
+
, D
- ) = 0.
Step 4:
For
α
= 0.
,
D
α
= 0.565 > D
Hence,
H
0
is not rejected.
Arrange R
(i)
from
smallest to largest D
+
= max {i/N – R
(i)
}
D
-^
= max {R
(i)
- (i-1)/N}
R
(i)
- (i-1)/N
i/N – R
(i)
i/N
R
(i)
Tests for Autocorrelation
[Tests for RN]
Testing the autocorrelation between every m numbers(m is a.k.a. the lag)
The autocorrelation
m
between numbers:
, Ri
i+m
i+2m
i+(M+1)m
is the largest integer such that
Hypothesis:
If the values are uncorrelated:
For large values of M, the distribution of the estimator of
m
denoted
is approximately normal.
N
)m
(M
i
≤
1
ρ
m
H
0
:
ρ
m
=
0,
if numbers are independent
H
1
:
ρ
m
≠
0,
if numbers are dependent
Tests for Autocorrelation
[Tests for RN]
Test statistics is:
Z
0
is distributed normally with mean =
0
and variance =
1
If
m
> 0, the subsequence has positive autocorrelation
High random numbers tend to be followed by high ones, and vice versa.
If
m
< 0, the subsequence has negative autocorrelation
Low random numbers tend to be followed by high ones, and vice versa.
Z
0
=
ˆ ρ
m
ˆ σ
ˆ ρ
m