## Generate random numbers using linear congruential method.

From Probability Concepts and Random Number Generation chapter in PU/ Simulation and Modelling 0 71 Views

Generate random numbers using linear congruential method with Xi = 27, a = 17, c = 43, and m = 100. And test their uniformity with Kolmogorov Smirnov test with 5% level of significance. [D0.05 = 0.565]

on 14 Apr, 2022 0 We have

Xi = 27, a = 17, c = 43, m = 100

Then using LCM,

X(i+1) = (a*Xi + c) mod m

X1 = (17*27 + 43) mod 100 = 2

X2 = (17*2 + 43) mod 100 = 77

X3 = (17*77 + 43) mod 100 = 52

X4 = (17*52 + 43) mod 100 = 27

X5 = (17*27 + 43) mod 100 = 2

Now,

R1 = X1/m = 2/100 = 0.02

R2 = X2/m = 77/100 = 0.77

R3 = X3/m = 52/100 = 0.52

R4 = X4/m = 27/100 = 0.27

R5 = X5/m = 2/100 = 0.02

Now using KS-test

 Ri 0.02 0.77 0.52 0.27 0.02 (i/n - Ri) 0.18 -0.37 0.08 0.53 0.98 (Ri - (i-1)/n) 0.02 0.57 0.12 -0.33 -0.78

Then

D+ = MAX(i/n - Ri) = 0.98

D- = MAX(Ri - (i-1)/n) = 0.57

D = MAX(D+, D-) = 0.98

Since D > Da hence the random numbers generated are not uniform