CSC328 · 2078 · 5 marks
Use Multiplicative congruential method to generate a sequence of random numbers with X=7, a=11 m=16.
Use Multiplicative congruential method to generate a sequence of random numbers with X=7, a=11 m=16. [5]
Multiplicative Congruential Method
Given
| Parameter | Value |
|---|---|
| $X_0$ (seed) | 7 |
| $a$ (multiplier) | 11 |
| $m$ (modulus) | 16 |
| $c$ | 0 (multiplicative case) |
Solution
Recurrence: $X_{n+1} = (a \cdot X_n) \bmod m = (11 \cdot X_n) \bmod 16$
Iteration 1: $$X_1 = (11 \times 7) \bmod 16 = 77 \bmod 16 = 13 \quad (77 = 4\times16 + 13)$$ $$R_1 = \frac{13}{16} = 0.8125$$
Iteration 2: $$X_2 = (11 \times 13) \bmod 16 = 143 \bmod 16 = 15 \quad (143 = 8\times16 + 15)$$ $$R_2 = \frac{15}{16} = 0.9375$$
Iteration 3: $$X_3 = (11 \times 15) \bmod 16 = 165 \bmod 16 = 5 \quad (165 = 10\times16 + 5)$$ $$R_3 = \frac{5}{16} = 0.3125$$
Iteration 4: $$X_4 = (11 \times 5) \bmod 16 = 55 \bmod 16 = 7 \quad (55 = 3\times16 + 7)$$ $$R_4 = \frac{7}{16} = 0.4375$$
Iteration 5: $$X_5 = (11 \times 7) \bmod 16 = 77 \bmod 16 = 13$$
Since $X_5 = X_1 = 13$, the sequence repeats. Period = 4.
Summary Table
| $n$ | $X_n$ | $X_{n+1}=(11 X_n)\bmod16$ | $R = X_{n+1}/16$ |
|---|---|---|---|
| 0 | 7 | 13 | 0.8125 |
| 1 | 13 | 15 | 0.9375 |
| 2 | 15 | 5 | 0.3125 |
| 3 | 5 | 7 | 0.4375 |
| 4 | 7 | 13 | (repeats) |
Result
Sequence of integers: $13, 15, 5, 7, 13, \ldots$
Sequence of random numbers: $$R = {0.8125,\ 0.9375,\ 0.3125,\ 0.4375, \ldots}$$
The period is 4, short because $m = 16$ is small.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.