90 likes | 100 Views
Random Number Generators. x n = f ( x n-1 , x n-2 ) where x 0 is seed Pseudo-random since, given the same seed, the sequence is repeatable and deterministic Cycle length – length of repeating sequence Example: x n = a x n-1 + b mod m. seed. cycle. period. k. D = S.
E N D
Random Number Generators xn = f ( xn-1, xn-2) where x0 is seed • Pseudo-random since, given the same seed, the sequence is repeatable and deterministic • Cycle length – length of repeating sequence • Example: xn = a xn-1 + b mod m seed cycle period
k D = S (oi – ei)2 ei i=1 Testing Random Numbers Chi-Square test • Discreet distributions, large sample sizes, general • Does an observed data set satisfy a specified distribution? • Prepare a histogram of observed data – k cells • D has chi-square distribution with k-1 degrees of freedom • Null hypothesis that observations come from distribution can not be rejected at significance a if computed D is less than C 2[1-a;k-1] • Works best with equiprobable cells – cell sizes so the frequencies are equal.
Chi-Square Example (observed-expected)2 expected 6.25 0.49 0.25 0.09 0.0 0.16 0.04 0.49 0.36 2.25 Sum = 10.38 whereas X 2[0.9;9] = 14.68
K+ = n max [Fo(x) – Fe(x)] x K- = n max [Fe(x) – Fo(x)] x Testing Random Numbers Kolmogorov-Smirnov test • Continuous distributions, small sample sizes, general • Based on differences between observed and expected CDFs • If K+ and K- are smaller than K[1-a;n] the observations are said to come from the distribution with level of significance a.
Kolmogorov-Smirnov Example Fo(xi) – Fe(xi) Fe(xi+1) – Fo(xi)
Kolmogorov-Smirnov Example j/n - xj xj – (j-1)/n
n-k 1 Rk = S (Ui – ½)(Ui+k – ½) n-k i=1 Rk! z1-a/2 /(12 n-k) Testing Random Numbers Serial-Correlation test • For a sequence of numbers, compute covariance between numbers that are k apart: xi and xi+k • Autocovariance at lag k, do for range of lags. • If the C.I. includes zero, not significant correlation 100(1-a)% CI:
Random Number Generators cycle seed period What does a test say about this sample?
Simulation Techniques Overview Simulation environments emulation Workloadparameters exec-drivensim SystemConfigparameters Result Data trace-drivensim -> discussion of timing-firstpaper Factorlevels stochasticsim