220 likes | 367 Views
Outline. generation of random variates convolution composition acceptance/rejection generation of uniform(0, 1) random variates linear congruential generators generator in ARENA tests of generators. Convolution. X = b 1 Y 1 + ... + b n Y n generate variates of Y 1 to Y n
E N D
Outline • generation of random variates • convolution • composition • acceptance/rejection • generation of uniform(0, 1) random variates • linear congruential generators • generator in ARENA • tests of generators
Convolution • X = b1Y1 + ... + bnYn • generate variates of Y1toYn • sum biYi to get X Example 2.6.2 for Binomial Example 2.6.3 for Erlang (k,) Example 2.5.3 for Triangular
Composition equivalent form in distribution F(x) = p1F1(x ) + ... + p1Fk(x ) use a zero-one uniform variate to determine the “type” and then generate the correspondingYvariate
Acceptance / Rejection • generate a variate from the uniform distribution on a disc of unit radius • 1o generate a variate of (X, Y) such that X,YX, Y~ i.i.d. uniform [-1, 1] • 2o accept (x,y) to be the desirable variate if x2 + y2 1; else go to 1o • result: uniform in {(x,y)| x2 + y2 1}
Acceptance / Rejection – Discrete Distribution • X ~ {pi};Y ~ {qi} such that pi/qi c for all i • 1o Generate y from Y ~ {qi}. • 2o Generate u from U. • 3o If cqyu < py, set x = y and stop; else go to 1o. primarily for continuous distributions whoseF-1is hard to find similar procedure applicable to continuous distribution with{pi}, {qi} replaced by the corresponding density functions
Pseudo-Random Numbers • linear congruential generator • Zi = (a Zi-1 + c) mod M • Ui = Zi/M • Z0 =seed(initial value) • for large Mand suitably chosen a, c, M • Zi approximately ~ discrete uniform [0, M] • Ui approximately ~ uniform [0, 1]
Comments on Linear Congruential Generators • {Zi}:a deterministic sequence given Z0 • sequence can change with seeds • sequences may not of full cycles (< M) • random numbers from LCGlie on planes of a hyper unit cube
Comments on Linear Congruential Generators • all right to use multiplicative LCG, i.e., c = 0 • full period for suitable choice of M and a • Common Multiplicative LCG
Zn / 4294967088 if Zn > 0 4294967087 / 4294967088 if Zn = 0 Un = The Current (2000) Arena RNG Two simultaneous recursions • use some but not all idea of LCG • CMRG - Combined multiple recursive generator An = (1403580 An-2– 810728 An-3) mod 4294967087 Bn = (527612 Bn-1– 1370589 Bn-3) mod 4294944443 Zn = (An–Bn) mod 4294967087 Seed = a six-vector of first three An’s, Bn’s
The Current (2000) Arena RNG – Properties • extremely good statistical properties • good uniformity in up to 45-dimensional hypercube • cycle length = 3.1 1057 • to cycle, all six seeds must match up • on 600 MHz PC: 8.4 1040 millennia to exhaust • only slightly slower than old LCG
The Current (2000) Arena RNG – Streams and Substreams • automatic streams and substreams • 1.8 1019 streams of length 1.7 1038 each • a stream: 2.3 1015 substreams of length 7.6 1022 each • default stream is 10 (historical reasons) • possible to specify a different stream • e.g., EXPO(6.7, 4) to use stream 4 • ARENA automatically advances to next substream in each stream for each replication • helps synchronize for variance reduction
Statistical Tests of Zero-One Random Number Generators • check whether data are from i.i.d. unif[0, 1] • quick test: mean and variance • goodness of fit: 2 test; K-S test • i.i.d.: j-lag correlation; run-up length • philosophy of tests: whether empirical evidence supports the statistical property under consideration
Quick Tests by Excel confidence Interval? sample variance? mean?
Goodness of Fit Test – 2Test • idea: the actual number of sample points in a given range should be close to the expected number in some sense • Mranges (categories) • ei: expected # of sample values in the ith range • ai: actual # of sample values in the ith range
Goodness of Fit Test – 2 Test approximately 2distribution of M-1 degree of freedom lose one degree of freedom for each estimated parameter
Theory and Main Idea of 2 Goodness of Fit Test • (X1, X2, ..., Xk) ~ Multinomial (n; p1, p2, ..., pk)
decision: if , reject H0; otherwise, accept H0. Goodness-of-Fit Test • “better” to have ei = ej for i not equal to j • for this method to work, ei 5 • choose significant level
F(x) x Goodness of Fit Test – K-S Test compare with the distribution of unif[0, 1] empirical distribution
largest difference Goodness of Fit Test – K-S Test find the “distance” between the empirical data and the uniform [0, 1] distribution for n 20, D0.05 1.36/(n)0.5 D0.01 1.63/(n)0.5 F(x) the largest difference follow certain well defined distribution x
j-lag Correlation Test cov(UiUi+j)/V(Ui) • i.i.d. uniform [0, 1] random variables: covariance stationary random variables • estimate j by: • if the data are truly uniform [0, 1]:
values of random variates discard order of random variates new length of runs becomes: 3, 4, 1, 0, 2, 1, 0, 2 Run-up Length Test run ups new length of runs becomes: 3, 4, 1, 0, 2, 1, 0, 2 can show that the lengths of runs are i.i.d. after deleting the numbers that start runs
Run-up Length Test • distribution of lengths (after deleting numbers that start runs): • can use goodness of fit test to check the distributions of the run lengths