Generation of Random Numbers and Random Observations
Generation of Random Numbers and Random Observations
Example :
38 IX = 937513
71 CALL RANDU (IX, IY, YFL)
IX = IY
Additive Congruential Generator
(Knuth)
Features:
• Requires as its seed, a sequence of n numbers x1,
x2, ……, xn
• Equation Xj = (Xj-1 + Xj-n ) mod m
Advantages:
• Speedy since no multiplication is required.
• Can yield periods greater than m.
Disadvantage:
• Theoretical behavior is not well understood as
the behavior of mixed congruential method.
Example of additive congruential
method
• Let m = 10, X1 = 1, X2 = 2, X3 = 4, X4 = 8, X5 = 6
• X6 = (X5 + X1)mod 10 = (6 + 1) mod 10 = 7
• X7 = (X6 + X2)mod 10 = (7 + 2) mod 10 = 9
• X8 = (X7 + X3)mod 10 = (9 + 4)mod 10 = 3
• X9 = (X8 + X4)mod 10 = (3 + 8)mod 10 = 1
• X10 = (X9 + X5)mod 10 = (1 + 6)mod 10 = 7
• X11 = (X10 + X6)mod 10 = (7 + 7)mod10 = 4
• X12 = (X11 + X7)mod 10 = (4 + 9)mod 10 = 3
• X13 = (X12 + X8)mod 10 = (3 + 3)mod 10 = 6
• X14 = (X13 + X9)mod 10 = (6 + 1)mod 10 = 7
• X15 = (X14 + X10)mod 10 = (7 + 7)mod 10 = 4
• X16 = (X15 + X11)mod 10 = (4 + 4)mod 10 = 8
• X17 = (X16 + X12)mod 10 = (8 + 3)mod 10 = 1
• X18 = (X17 + X13)mod 10 = (1 + 6)mod 10 = 7
• X19 = (X18 + X14)mod 10 = (7 + 7)mod 10 = 4
• X20 = (X19 + X15)mod 10 = (4 + 4)mod 10 = 8
Quadratic Congruential Generator
(Conveyou)
Features:
• m is a power of 2
• Nearly equivalent to midsquare method but
has a longer period.
• Equation: Xi+1 = (Xi (Xi + 1))mod m
• X0 must satisfy the relation X0 mod 4 = 2
Example of Quadratic Congruential
Generator
• X0 = 2 m = 16 2 mod16 = 2
• X1 = [2(3)]mod 16 = 6
• X2 = [6(7)]mod 16 = 10
• X3 = [10(11)]mod 16 = 14
• X4 = [14(15)]mod 16 = 2
• X5 = [2(3)]mod 16 = 6
• X6 = [6(7)]mod 16 = 10
• X7 = [10(11)]mod 16 = 14
• X8 = [14(15)]mod 16 = 2