1) Consider a linear congruential random number generator with parameters a = 35, c = 20 and m = 100.
a- Generate 5 random numbers by using this method. Use 84.
b- By using inverse transform method, generate 2 random variate for an exponential distribution with parameter λ = 0.5. Use the first two random numbers you generated in part a.
1) generating random numbers using linear congreuential number generator
a= 35
c= 20
m=100
X0= 84, to generate 5 random numbers
Xi+!= (a Xi+c)* mod m
Ri= Xi/m
X1= ( 35 x 84 + 20) mod 100= 60, R1= X1/m= 60/100= 0.6
X2= (35 x 60 + 20) mod 100= 20,, R2=X2/m= 20/100= 0.2
X3= ( 35x20+20) mod 100= 20, R3=X2/m= 20/100= 0.2
X4= (35x20+20) mod 100= 20, R4=X2/m= 20/100= 0.2
X5= (35x20+20) mod100= 20, R5=X2/m= 20/100= 0.2
5 random numbers are = 0.6, 0.2,0.2,0.2,0.2
b) inverse sampling method
to find random variates first we need inverse cdf for it
cdf of exponential = 1-e-px, p= lambda
let u = 1-e-px, , u-1= -e-px, 1-u= e-px,, -px= log(1-u), x=- log(1-u)/p
so our inv-cdf = - log(1-u)/p
using two random numbers from above we have
Xi= - log(1-u)/p
X1= -log(1-0.6)/0.5= 1.8
X2=-log(1-0.2)/0.5= 0.4
two random variates are 1.8, 0.4
Get Answers For Free
Most questions answered within 1 hours.