Chapter 6
Chapter 6
Chapter 6
Random Number
Overview
6.1 Properties of Random Number
6.2 Generation of Pseudo Random Number
6.3 Random Number Generation Method
6.4 Test for Random Number
6.5 Generating Discrete Distribution
6.6 Inversion, Rejection, Composition and Convolution
Random Number
Therefore, the generated random numbers are 0.031, 0.333 and 0.319
Maximum Period Calculation
Example 1 (Case 1): Using the Linear congruential method, find the
period of the generator for a = 5, m = 4 , and X0 = 1 and c = 43.
Solution,
m can be expressed as 22 = 4, c = 43 (non-zero) and is relatively prime
to m, and ‘a’ satisfies a = 1 + 4k when k is taken as 1 i.e. 5 = 1 + 4*1
Hence, P = m = 4.
Maximum Period Calculation Examples
Maximum Period Calculation Examples
The top row in above table lists the number from smallest to largest.
The computation for D+ = 0.26 and D- = 0.21.
Therefore, D = max(0.26, 0.21) = 0.26.
Example
• Step 3: Compare the Calculated value with Critical value in table.
The critical value of D, obtained from table for α = 0.05 and N = 5 is
0.565.
Since, the computed value, 0.26 is less than tabulated critical value.
0.565, the hypothesis that the distribution of the generated numbers
is the uniform distribution is not rejected.
Table for Kolmogorov-Smirnov Test
Example
• Perform Kolmogorov-Smirnov test for the following random numbers
with level of significance of α = 0.05. The critical value for α = 0.05 is
0.410 for sample size N=10.
• Random numbers are: 0.24, 0.89, 0.11, 0.61, 0.23, 0.86, 0.41, 0.64,
0.50, 0.65
Chi Square Test
• The chi-square test uses the sample statistics:
where Oi is the observed number in the ith class, Ei is the expected number in
the ith class, and n is the number of classes. For the uniform distribution Ei ,
the expected number in each class is given by:
Ei = N/n
for equally spaced classes, where N is the total number of observations. It can
be shown that the sampling distribution of is approximately the chi-square
distribution with n-1 degrees of freedom.
Chi-Square Test
Steps Involved.
1. Determine the appropriate test
2. Establish the level of significance:α
3. Formulate the statistical hypothesis
4. Calculate the test statistic
5. Determine the degree of freedom
6. Compare computed test statistic against a tabled/critical value
Chi-Square Test (Example 1)
Chi-Square Test (Example 1)
Solution,
Step 1: Formulate the Hypothesis:
H0: Ri = U[0,1]
H1: Ri ≠ U[0,1]
Step 2: Calculate the expected frequency as:
Ei = N/n
= 100/10 = 10
Chi-Square Test (Example 1)
Step 3: Perform the calculation as:
• There are a total of 6, 3s therefore number of gaps become 5 and gap length
between first two 3s is 10, then 7, 0, 2 and 3 respectively.
• The probability of a particular gap length can be determined by a Bernoulli trail.
Gap Test
• The theoretical frequency distribution for randomly ordered digits is
given by:
Case-I: P(4 different digits) = P(2nd diff. from 1st) * P(3rd diff. from 1st &
2nd) * P(4th diff. from 1st, 2nd & 3rd)
= 0.9 * 0.8 * 0.7 = 0.504
Case-II: P(4 like digits) = P(2nd digit same as 1st) * P(3rd digit
same as 1st) * P(4th digit same as 1st)
= 0.1 * 0.1 * 0.1 = 0.001
Poker Test (Example)
Case-III: P(3 like digits) = P(2nd digit same as 1st) * P(3rd digit same as 1st) * P(4th digit diff. from 1st) * No. of possible
combinations for 3 like digits from 4 digits
= 0.1 * 0.1 * 0.9 * 4C3= 0.1 * 0.1 * 0.9 * 4 = 0.036
Case-IV: P(1 pair) = P(2nd digit same as 1st in the pair) * P(3rd digit diff. from 1st) * P(4th digit diff. from 1st & 3rd)* No. of
possible combinations for a pair from 4 digits
Case-V: P(2 pairs) =P(2nd digit same as 1st in the pair) * P(3rd digit diff. from 1st) * P(4th digit same as 3rd)* No. of possible
combinations for two pairs from 4 digits
= 0.1 * 0.9 * 0.1 *( * 4C2 ) = 0.1 * 0.9 * 0.1 * 3 = 0.027
OR,
Case-V: P(2 pairs) = 1 - P(4 different digits) - P(3 like digits) - P(4 like digits) - P(1 pair)
= 1 – 0.504 – 0.036 – 0.001 – 0.432 = 0.027
Poker Test (Example)
• Step 3: With N = 1000, let’s summarize the results for Poker’s test in
the following table:
Combination Distribution (i) Observed Frequency Expected Frequency (Oi – Ei)2/Ei
Oi Ei = Prob.*N
4 different digits 540 504 2.571
3 like digits 50 36 5.44
4 like digits 20 1 361
1 pair 320 432 29.037
2 pairs 70 27 68.48
1000 1000 466.528
Poker Test (Example)
Step 4: Compare the calculated value with critical value in the table.
Case-II: P(5 same digits) = P(2nd same as1st) * P(3rd same as 2nd) * P(4th same
as 3rd) * P(5th same as 4th)
= 0.1 * 0.1 * 0.1* 0.1 = 0.0001
Poker Test (Example)
Case-III: P(4 same digits) = P(2nd same as 1st) * P(3rd same as 2nd) * P(4th
same as 3rd) * P(5th diff. from 1st) * 5C4
= 0.1 * 0.1 * 0.1* 0.9*5 = 0.0045
Case-VI: P(One Pairs) = P(2nd same as 1st) * P(3rd differ from 1st) * P(4th diff from 1st and 3rd ) * P(5th diff. from 1st ,
3rd and 4th ) * 5C3
= 0.1 * 0.9 * 0.8* 0.7*10 = 0.504
Case-VII: P(Two Pairs) = P(2nd same as 1st) * P(3rd differ from 1st) * P(4th digit same as 3rd ) * P(5th diff. from 1st and
3rd ) * ½ * 4C2 * 5C1
= 0.1 * 0.9 * 0.1 * 0.8 * 3 * 5 = 0.108
OR,