슬라이드 1 - Winston-Salem State University
Download
Report
Transcript 슬라이드 1 - Winston-Salem State University
Tests for
Random Number Generators
Jin Ui Yim
Inseok Oh
Junghoon Yang
Desirable properties of random numbers
Uniformity
Independence
Methods to test random numbers
Frequency test (Uniformity)
Uses the chi-square test to compare
the distribution of the set of numbers
generated to a uniform distribution.
Autocorrelation test (Independence)
Tests the correlation between numbers and
compares the sample correlation to the
expected correlation, zero.
Frequency test (Chi-Square Method)
Oi - the observed number in the ith class
Ei - the expected number in the ith class
n - the number of classes
X0
2
(Oi Ei )
Ei
i 1
n
2
Frequency test (Chi-Square Method)
For the uniform distribution,
Ei , the expected number in each class is given by for
equally spaced classes.
N
Ei
n
N - the total number of observations
n - the number of classes
Generating random number source(1)
double[] data = new double[100];
//This object generates random number between 0 and 1
Random randomGenerator = new Random();
for ( int n = 0; n < 100; n++ )
{
//Makes random number
x = randomGenerator.nextDouble();
data[n] = x;
}
Generated random number
0.34
0.83
0.96
0.47
0.79
0.99
0.37
0.72
0.06
0.18
0.90
0.76
0.99
0.30
0.71
0.17
0.51
0.43
0.39
0.26
0.25
0.79
0.77
0.17
0.23
0.99
0.54
0.56
0.84
0.97
0.89
0.64
0.67
0.82
0.19
0.46
0.01
0.97
0.24
0.88
0.87
0.70
0.56
0.56
0.82
0.05
0.81
0.30
0.40
0.64
0.44
0.81
0.41
0.05
0.93
0.66
0.28
0.94
0.64
0.47
0.12
0.94
0.52
0.45
0.65
0.10
0.69
0.96
0.40
0.60
0.21
0.74
0.73
0.31
0.37
0.42
0.34
0.58
0.19
0.11
0.46
0.22
0.99
0.78
0.39
0.18
0.75
0.73
0.79
0.29
0.67
0.74
0.02
0.05
0.42
0.49
0.49
0.05
0.62
0.78
Chi-Square Test Source(1)
Chi-Square Test Source(2)
X0
2
(Oi Ei )
Ei
i 1
n
2
Frequency test
The chi-square test conducted with a=0.05 to test
for whether the randomly generated data are
uniformly distributed.
The null hypothesis of a uniform distribution is
not rejected when the result of chi-square is
smaller than the tabulated value.
X X
2
0
2
0.05,9
16.9
Frequency test
double resultOfChiSquareTest = ChiSquareTest( data );
if( resultOfChiSquareTest < 16.9)
System.out.println("The null hypothesis of a uniform
distribution is not rejected.");
else
System.out.println("The null hypothesis of a uniform
distribution is rejected.");
Autocorrelation Use
Economy- Stock Market
GIS
Architecture Engineering
Information Technology - CDMA
Autocorrelation Notion
The notion is that
numbers on the
sequence might be
related.
We will select the
number with same
distance.
R1
R4
R7
R10
3
Autocorrelation
m - m is the lag, the space between the numbers being
tested.
i - i is the index, or the number in the sequence that
you start with.
N - The number of numbers generated in a sequence.
M - M is the largest integer such that
ˆ im
Z 0 ˆ
im
Pim - the estimator that is appr
oxomitely normal
Qpim - the standard deviation
of the estimator
Autocorrelation
Equation-Schmidt and Taylor
M
1
Ri km Ri (k 1)m 0.25
ˆim
M 1 k 0
Assume i = 1
Ri
Ri nm
n = k+1
m=3
R1
R4
As n is
changed
R7
R10
i (k 1)m n
So, We can calculate the k value.
Autocorrelation
Equation-Schmidt and Taylor
i (k 1)m n
i km m n( everyth in gs 0)
km n i m
k ( n i m) / m
let :: i 1, m 3, n 5 0
k (5 0 1 3) / 3
k 1 5. xxxxxx
k 15
Autocorrelation
Equation-Schmidt and Taylor
ˆ
im
13M 7
12( M 1)
Autocorrelation Accept / Reject
ˆ im
z / 2 Z 0
z / 2
ˆim
Reject
ACCEPT
Reject
Autocorrelation Test Source
i (k 1)m n
M
ˆim 1 Ri km Ri (k 1)m 0.25
M 1 k 0
ˆ
im
13M 7
12( M 1)
Z0
ˆ im
ˆ
im
Autocorrelation Test Source(2)
z / 2
ˆ im
Z 0 ˆ z / 2
im
Result
0.21449970335028734
0.14016906690349618
0.1645030518088607
0.8638687961841897
0.2909116149745625
0.08590384803754958
0.9533828724917218
0.9936753768377475
0.7388814369469828
0.8008823252683048
0.05016115669494969
0.3787119891281151
0.4768874088196027
0.34120913234270767
0.02096581516091489
0.810399112996363
0.8352798169604146
0.1341231494235261
0.40901395536426344
0.9739110447728812
0.8713763536773295
0.645201328845651
0.27027552460170856
0.9295796431460743
……………………...
========== Frequency Tests(Chi-Square) ==========
a = 0.05,X^2_0.05.9 = 16.9
The result of Chi-Square : 4.4
The null hypothesis of a uniform distribution is not rejected.
========== Tests for Autocorrelation ==========
m = 5,i = 2
N = 50,M(i+(M+1)m <= N) = 8
a = 0.05,Za/2 = 1.96
The result of AutoCorrelation : 0.6440408970482641
The null hypothesis of an autocorrelation is not rejected.
References
Discrete Event System Simulation 4rd
edition
CH7.1, CH7.4
http://www.unf.edu/~rita0001/research/inde
x.html(Frequency test )
http://www.itl.nist.gov/div898/software/data
plot/refman1/auxillar/freqtest.htm(Autocorrelat
ion Test )
References
www.math.com
www.wordiq.com
www.jstor.org(durbim-watson test)
http://210.125.93.11/economics/dteco.asp?v
iew=1&word=자기상관 (economic book)
http://chejucyber.cheju.ac.kr/kanggc/em/cha
p5/chap5.hwp (Jeju university)