Test for randomness Chi square test We can

  • Slides: 10
Download presentation
Test for randomness : Chi square test We can say how probable or improbable

Test for randomness : Chi square test We can say how probable or improbable certain types of events are. The difference between observed Ys and expected nps V = (Y 2 – np 2) 2 + (Y 3 – np 3) 2 + … + (Y 12 – np 12) 2 What is the probability what V is this high using true dice? December 1999 Prabhas Chongstitvatana 1

Suppose that every observation can fall into one of k categories. We take n

Suppose that every observation can fall into one of k categories. We take n independent observations. Let ps be the probability that each observation falls into category s, and let Ys be the number of observations that actually do fall into category s. Weighted by the prob. of occurrence nps December 1999 Prabhas Chongstitvatana 2

Expanding (Ys – nps) 2 = Y 2 – 2 nps Ys + n

Expanding (Ys – nps) 2 = Y 2 – 2 nps Ys + n 2 ps 2 and Y 1 + Y 2 + … Yk = n p 1 + p 2 + … pk = 1 v = k – 1 the number of degree of freedom is k – 1. December 1999 Prabhas Chongstitvatana 3

Chi-square distribution table says “The quantity V will be less than or equal to

Chi-square distribution table says “The quantity V will be less than or equal to x with approximate probability p, if n is large enough”. How large should n be? >= 5 December 1999 Rule of thumb is nps Prabhas Chongstitvatana 4

Example five Chi-square test on three data of four generators. December 1999 Prabhas Chongstitvatana

Example five Chi-square test on three data of four generators. December 1999 Prabhas Chongstitvatana 5

B : x 0 = 0, a = 3141592653, c = 2718281829, m =

B : x 0 = 0, a = 3141592653, c = 2718281829, m = 2 35 C : x 0 = 0, a = 2 7 + 1 , c = 1, m = 2 35 D : x 0 = 47194118, a = 23, c = 0, m = 10 8 + 1 F : x 0 = 314159265, a = 2 18 + 1, c = 1, m = 2 35 Conclusion, B and D are satisfactory, C is on the borderline, F is unsatisfactory. December 1999 Prabhas Chongstitvatana 6

Other tests Kolmogorov-Smirnov test (available in SPSS package( Frequency test, serial test, gap test,

Other tests Kolmogorov-Smirnov test (available in SPSS package( Frequency test, serial test, gap test, Poker test (partition test), Coupon’s collector test, permutation test, run test, maximum -of-t test, collision test, serial correlation test, tests on subsequences Spectral test December 1999 Prabhas Chongstitvatana 7

Advise for RNG The seed number X 0 may be chosen arbitrarily. The number

Advise for RNG The seed number X 0 may be chosen arbitrarily. The number m should be large. The computation (a. X + c) mod m must be done exactly with no roundoff error. If m is the power of 2, pick a so that a mod 8 = 5 to ensure max period and high potency. December 1999 Prabhas Chongstitvatana 8

The muliplier a should preferably be chosen between. 01 m and. 99 m and

The muliplier a should preferably be chosen between. 01 m and. 99 m and is binary digits should not have a simple, regular pattern. The value of c is immaterial when a is a good multiplier, except that c must be no factor in common with m. The least significant (right-handed) digits of X are not very random. It is generally best to think of X as a random fraction X/m between 0 and 1. December 1999 Prabhas Chongstitvatana 9

Some good RNG a, m 256 , 137 352 , 3141592221 35 2 ,

Some good RNG a, m 256 , 137 352 , 3141592221 35 2 , 15 5 35 2 , 17059465 32 2 , 1664525 1 - 31 2 , 314159269 48 2 , 31167285 64 2 , 6364136223846793005 December 1999 Prabhas Chongstitvatana 10