Subjects probability and statistics

Random Number Generation

Step-by-step solutions with LaTeX - clean, fast, and student-friendly.

Search Solutions

Random Number Generation


1. **Problem statement:** (a) Transform random numbers uniform on $[0,1]$ to uniform on $[-11,17]$. (b) Generate three two-digit random integers and corresponding random numbers using linear congruential method with $X_0=27$, $a=8$, $c=47$, $m=100$. (c) Generate four three-digit random integers and corresponding random numbers using multiplicative congruential method with $X_0=117$, $a=43$, $m=1000$. (d) Determine if given linear congruential generators can achieve maximum period and state restrictions on $X_0$. --- 2. **(a) Transforming uniform random numbers:** If $U$ is uniform on $[0,1]$, to transform to $[A,B]$ use: $$X = A + (B - A)U$$ Here, $A = -11$, $B = 17$, so: $$X = -11 + (17 - (-11))U = -11 + 28U$$ This means multiply $U$ by 28 and subtract 11 to get uniform on $[-11,17]$. --- 3. **(b) Linear congruential method (LCG):** Formula: $$X_{n+1} = (aX_n + c) \bmod m$$ Given $X_0=27$, $a=8$, $c=47$, $m=100$. Calculate: - $X_1 = (8 \times 27 + 47) \bmod 100 = (216 + 47) \bmod 100 = 263 \bmod 100 = 63$ - $X_2 = (8 \times 63 + 47) \bmod 100 = (504 + 47) \bmod 100 = 551 \bmod 100 = 51$ - $X_3 = (8 \times 51 + 47) \bmod 100 = (408 + 47) \bmod 100 = 455 \bmod 100 = 55$ Corresponding random numbers $U_n = X_n / m$: - $U_1 = 63/100 = 0.63$ - $U_2 = 51/100 = 0.51$ - $U_3 = 55/100 = 0.55$ --- 4. **(c) Multiplicative congruential method (MCG):** Formula: $$X_{n+1} = (aX_n) \bmod m$$ Given $X_0=117$, $a=43$, $m=1000$. Calculate: - $X_1 = (43 \times 117) \bmod 1000 = 5031 \bmod 1000 = 31$ - $X_2 = (43 \times 31) \bmod 1000 = 1333 \bmod 1000 = 333$ - $X_3 = (43 \times 333) \bmod 1000 = 14319 \bmod 1000 = 319$ - $X_4 = (43 \times 319) \bmod 1000 = 13717 \bmod 1000 = 717$ Corresponding random numbers $U_n = X_n / m$: - $U_1 = 31/1000 = 0.031$ - $U_2 = 333/1000 = 0.333$ - $U_3 = 319/1000 = 0.319$ - $U_4 = 717/1000 = 0.717$ --- 5. **(d) Maximum period and restrictions on $X_0$:** For maximum period: - Mixed LCG (with $c \neq 0$) achieves max period $m$ if: 1. $c$ and $m$ are relatively prime. 2. $a-1$ divisible by all prime factors of $m$. 3. If $m$ divisible by 4, then $a-1$ divisible by 4. - Multiplicative LCG (with $c=0$) achieves max period $m-1$ if: 1. $m$ is prime or power of prime. 2. $a$ is a primitive root modulo $m$. 3. $X_0$ is relatively prime to $m$. Check each: i) Mixed LCG: $a=2814749767109$, $c=59482661568307$, $m=2^{48}$. - $c$ and $m$ are relatively prime? Since $m$ is power of 2, $c$ must be odd. - $c$ is odd (ends with 7), so yes. - $a-1$ must be divisible by 2 (prime factor of $m$) and by 4 (since $m$ divisible by 4). - Check $a-1$ even and divisible by 4. - $a$ is odd, so $a-1$ is even. - Check divisibility by 4: $2814749767109 -1 = 2814749767108$ divisible by 4? Yes. - So max period $m=2^{48}$ achievable. - $X_0$ must be odd (relatively prime to $m$). ii) Multiplicative LCG: $a=69069$, $c=0$, $m=2^{32}$. - Max period $m-1=2^{32}-1$ if $a$ is primitive root mod $m$. - Since $m$ is power of 2, multiplicative LCG max period is $m/4=2^{30}$ if $a \equiv 3 \mod 8$ or $5 \mod 8$. - $69069 \bmod 8 = 5$, so max period $2^{30}$ achievable. - $X_0$ must be odd. iii) Mixed LCG: $a=4951$, $c=247$, $m=256$. - $c=247$ and $m=256$ are relatively prime? Yes, since 247 is odd and 256 is power of 2. - Prime factors of $m$ is 2. - $a-1=4950$ divisible by 2? Yes. - $m$ divisible by 4, so $a-1$ divisible by 4? $4950 \bmod 4 = 2$, no. - So max period not achievable. iv) Multiplicative LCG: $a=6507$, $c=0$, $m=1024=2^{10}$. - Max period is $m/4=256$ if $a \equiv 3$ or $5 \mod 8$. - $6507 \bmod 8 = 3$, so max period 256 achievable. - $X_0$ must be odd. --- **Final answers:** (a) $X = -11 + 28U$ (b) $X_1=63$, $U_1=0.63$; $X_2=51$, $U_2=0.51$; $X_3=55$, $U_3=0.55$ (c) $X_1=31$, $U_1=0.031$; $X_2=333$, $U_2=0.333$; $X_3=319$, $U_3=0.319$; $X_4=717$, $U_4=0.717$ (d) - (i) Max period $2^{48}$ achievable; $X_0$ odd. - (ii) Max period $2^{30}$ achievable; $X_0$ odd. - (iii) Max period not achievable. - (iv) Max period 256 achievable; $X_0$ odd.