19
Random Number Generation © neo

Random Number Generation

Embed Size (px)

DESCRIPTION

Everything about Random Number Generation in Simulation and Modelling. Various Tests used.

Citation preview

Page 1: Random Number Generation

Random Number Generation

© neo

Page 2: Random Number Generation

INDEPENDENCE TEST

• Autocorrelation Test• Gap Test• Poker Test

© neo

Page 3: Random Number Generation

© neo

AUTOCORRELATION TEST

Page 4: Random Number Generation

AUTOCORRELATION TEST• The tests for Autocorrelation are concerned with the dependence between numbers in a sequence. For eg.

0.12 0.01 0.23 0.28 0.89 0.31 0.64 0.28 0.83 0.930.99 0.15 0.33 0.35 0.91 0.41 0.60 0.27 0.75 0.880.68 0.49 0.05 0.43 0.95 0.58 0.19 0.36 0.69 0.87

© neo

Page 5: Random Number Generation

AUTOCORRELATION TEST• From a visual inspection, these numbers appear to be random, and they would probably pass all tests presented to this point.

0.12 0.01 0.23 0.28 0.89 0.31 0.64 0.28 0.83 0.930.99 0.15 0.33 0.35 0.91 0.41 0.60 0.27 0.75 0.880.68 0.49 0.05 0.43 0.95 0.58 0.19 0.36 0.69 0.87

© neo

Page 6: Random Number Generation

AUTOCORRELATION TEST• From a visual inspection, these numbers appear to be random, and they would probably pass all tests presented to this point.

0.12 0.01 0.23 0.28 0.89 0.31 0.64 0.28 0.83 0.930.99 0.15 0.33 0.35 0.91 0.41 0.60 0.27 0.75 0.880.68 0.49 0.05 0.43 0.95 0.58 0.19 0.36 0.69 0.87

© neo

Page 7: Random Number Generation

AUTOCORRELATION TEST• The test requires the computation of autocorrelation between every m numbers, starting with the ith number .• Thus the autocorrelation ρim between the following numbers would be of interest: Ri , Ri+m, Ri+2m, .. .. .. .., Ri+

(M+1)m.

Page 8: Random Number Generation

AUTOCORRELATION TEST• Where M is the largest integer such that i+(M+1)m<=N , where N is total number of values in sequence.• A nonzero autocorrelation implies a lack of independence, so following two tailed test is appropriate:H0 : ρim = 0

H1 : ρim ×= 0

Page 9: Random Number Generation

AUTOCORRELATION TEST• For large values of M, the distribution of the estimator of ρim , denoted ρim is approximately normal if the values Ri , Ri+m, Ri+2m, .. .. .. .., Ri+(M+1)m are uncorrelated, then the statistics can be as follows:

33

Z0 = ρim

33σρim

Page 10: Random Number Generation

© neo

GAP TEST

Page 11: Random Number Generation

GAP TEST• For each Uj in certain range, this test examines the length of ‘Gap’ between this element and the next element to fall in that range.•So if ä and ß are two real numbers such that 0 <= ä < ß <= 1 we are looking for the length of consecutive subsequences Uj, Uj+1,.. , Uj+(r+1)

© neo

Page 12: Random Number Generation

GAP TEST• Such that Uj and Uj+(r+1) are between ä and ß but the other elements in the subsequence are not (this is a gap of length r).•We would then perform chi-squared test on the results using the different lengths of gaps as the categories, and the probabilities are as follows:

© neo

Page 13: Random Number Generation

GAP TEST• Such that Uj and Uj+(r+1) are between ä and ß but the other elements in the subsequence are not (this is a gap of length r).•We would then perform chi-squared test on the results using the different lengths of gaps as the categories, and the probabilities are as follows:

© neo

Page 14: Random Number Generation

GAP TEST

p0 = p, p1= p(1-p), p2= p(1-p) , .. .., pk= p(1-p)

© neo

2 k

Here p= ß - ä which is probability that any element Uj is between ä and ß

Page 15: Random Number Generation

© neo

POKER TEST

Page 16: Random Number Generation

POKER TEST

© neo

• As with the gap test, the name of the poker test suggests its description. We examine n groups of five consecutive integers, and put each of these groups into one of the following categories:

Page 17: Random Number Generation

POKER TEST

© neo

•All different: ABCDE•One pair: AABCD•Two pairs: AABBC•Three of a kind: AAABC•Full house: AAABB•Four of a kind: AAAAB•Five of a kind: AAAAA

Page 18: Random Number Generation

POKER TEST• In a more intuitive way, let us consider a hand of k cards from k dierent cards.

• The probability to have exactly c different cards is

© neo

P(C=c) = 1 k!

k (k-c)!k

2Sk

c

Page 19: Random Number Generation

Thank you

© neo