Upload
pablo-hinojosa-nava
View
233
Download
0
Embed Size (px)
Citation preview
7/28/2019 Test Random Numbers
1/23
Test forRandomNumbers
Pablo Hinojosa NavaSelected topics of computational
science
http://www.ua.ac.be/main.aspx?c=.OODE2012&n=105102&ct=105102&e=290432&detail=2001WETCCWhttp://www.ua.ac.be/main.aspx?c=.OODE2012&n=105102&ct=105102&e=290432&detail=2001WETCCWhttp://www.ua.ac.be/main.aspx?c=.OODE2012&n=105102&ct=105102&e=290432&detail=2001WETCCWhttp://www.ua.ac.be/main.aspx?c=.OODE2012&n=105102&ct=105102&e=290432&detail=2001WETCCWhttp://www.ua.ac.be/main.aspx?c=.OODE2012&n=105102&ct=105102&e=290432&detail=2001WETCCW7/28/2019 Test Random Numbers
2/23
Index
1. Tests (Hypothesis testing)a. Kolmogorov-Smirnof testb. Chi-square test
c. Runs up and runs downd. Runs above and below mean
2. Simulating Coin Tossing Experiment
7/28/2019 Test Random Numbers
3/23
Tests properties
Uniformity-Frequency test
a)Kolmogorov-Smirnov
b)Chi-Square testIndependence
-Runs
c)Runs up and runs downd)Runs above and below mean
-Autocorrelation-Gap-Poker
7/28/2019 Test Random Numbers
4/23
Begining of the Tests
1. Formulate H0
(null hypothesis) in confrontation with H1
(alternative hypothesis)H
0-> the numbers are distributed uniformly or
independent on the interval [0,1]2. Level of significance must be stated (confidenceinterval)
is frequently set to 0,01 or 0,053. Measure the quantity of interest Q
4. Check Qt from the distribution table based on and:v= n-1 (n=number of intervals) (Chi-Square test)N (total number of numbers) (the rest of the tests)
5. If Q < Qtthen H
0is true else false
7/28/2019 Test Random Numbers
5/23
a) Kolmogorov-Smirnov test
1. Arrange the numbers in ascending order2. Compute
Q+ = max1 i N
{i/N - ri
}
Q- = max1 i N
{ ri
- i/N }
3. Choose Q (maximum between Q+ and Q-)4. Determine the critical value Q
tfrom the
next table for the specified and N5. If Q < Q
tthen numbers are uniformly
distributed else not
7/28/2019 Test Random Numbers
6/23
a) Kolmogorov-Smirnov testtable
7/28/2019 Test Random Numbers
7/23
a) Kolmogorov-Smirnov testexample
Example 2.9 Suppose that the five numbers0.44, 0.81, 0.14, 0.05, 0.93 are generated.So, N = 5. Let = 0.05. The calculations can
be facilitated by use of Table 2.2.
7/28/2019 Test Random Numbers
8/23
b)Chi-Square test
1. Fix the number of intervals n of equal length in [0, 1].2. Compute E = N/n
3. Compute the observed number Oiin ith interval for
i = 1, 2, . . . , n.4. Compute
5. Determine the critical value, Qt, from the next table for
the specified and n.
6. If Q < Qt then numbers are uniformly distributedelse not
7/28/2019 Test Random Numbers
9/23
b)Chi-Square test
table
7/28/2019 Test Random Numbers
10/23
7/28/2019 Test Random Numbers
11/23
7/28/2019 Test Random Numbers
12/23
Independence testsSome definitions
1. Run. A run is defined as a succession of similar eventspreceded and followed by a different event2. Length of run. The length of a run is the number of
events that occur in the run3. Up run. An up run is a sequence of numbers each ofwhich is succeeded by a larger number4. Down run. A down run is a sequence of numbers eachof which is succeeded by a smaller number
For the random number to be tested we give + or a -depending on whether theyare followed by a larger number or a smaller number.
7/28/2019 Test Random Numbers
13/23
Example
Consider this numbers:0.87, 0.15, 0.23, 0.45, 0.69, 0.32, 0.30, 0.19,0.24, 0.18, 0.65, 0.82, 0.93, 0.22, 0.81.
The sequence of + and is as follows: + + + + + + + +
So, the number of runs is 8, the number ofup runs is 4 and the number of down runs is4.
7/28/2019 Test Random Numbers
14/23
c)Runs up and runs down test I
1. Find X, the total number of runs in thegiven sequence of random numbers to betested.
2. Compute
3. Let N denote the total number of random
numbers in the sequence.4. If N 20, proceed further. Else, nothingcan be said about the independency of thenumbers.
7/28/2019 Test Random Numbers
15/23
c)Runs up and runs down test II
5. Compute
X number of runs
6. Determine the critical value, Qt, from the
next tables for the specified
7. If Q < Qt, the numbers are independent,
else, they are not.
7/28/2019 Test Random Numbers
16/23
c)Runs up and runs down tableI
7/28/2019 Test Random Numbers
17/23
c)Runs up and runs down tableII
7/28/2019 Test Random Numbers
18/23
c)Runs up and runs downexample
7/28/2019 Test Random Numbers
19/23
d)Runs above and below mean
The following steps will be carried out for theruns above and below mean procedure:1. Find X, the total number of runs in the
given sequence of random numbers to betested.2. Find the number n
1of random numbers
above the mean (total number of + signs)3. Find the number n
2of random numbers
below the mean (total number signs).
The cross check is N = n1 + n2 .
7/28/2019 Test Random Numbers
20/23
d)Runs above and below meanII
6. If n1
> 20 or n2
> 20, proceed further.
Else, nothing can be said about the indepen-
dency of the given random numbers
7/28/2019 Test Random Numbers
21/23
d)Runs above and below meanIII
8. Determine the critical value, Qt, from the
last tables for the specified .9. If Q < Q
t, the numbers are independent,
else, they are not.
7/28/2019 Test Random Numbers
22/23
d)Runs above and below meanexample
7/28/2019 Test Random Numbers
23/23
Simulating Coin Tossing Experiment
http://nlvm.usu.edu/en/nav/frames_asid_305_g_4_t_5.html
http://pbskids.org/cyberchase/games/probability/
http://pbskids.org/cyberchase/games/probability/http://pbskids.org/cyberchase/games/probability/http://pbskids.org/cyberchase/games/probability/http://nlvm.usu.edu/en/nav/frames_asid_305_g_4_t_5.htmlhttp://nlvm.usu.edu/en/nav/frames_asid_305_g_4_t_5.html