Write a computer program to generate uniformly distributed random integers in the interval m < x < n, where m and n are integers, according to the following algorithm:
Step 1 Let \(d=2^{31}\) and choose N (the number of random numbers to generate)
Step 2 Choose any seed integer \(Y\) such that \(10000 < Y < 999999\)
Step 3 Let \(i = 1\)
Step 4 Let \(Y = (15625Y + 22221) mod(d)\)
Step 5 Let \(X_i = m + floor[(n - m + 1)Y/d]\)
Step 6 Increment \(i\) by \(1: i = i + 1\)
Step 7 Go to Step 4 unless \(i = N + 1\)
Here, floor[p] means the largest integer not exceeding p.
As per definition, uniformly distributed random integers in the interval [m,n], will have an equal probability of being selected. If we let m = -500 and n = 500, then any number selected should have a probability of
\[P(X_i) = \frac{1}{n-m}\]
\[\frac{1}{500-(-500)} = \frac{1}{1000} = 0.001\]
The histogram with 5000 integers shows a uniform random distribution with minimum value of -500 and maximum value of 500.
The density plot shows uniform probability of 0.001 as expected.
For most choices of , the numbers \(X_1\), \(X_2\),… form a sequence of (pseudo) random integers as desired. One possible recommended choice is Y = 568731. To generate random numbers (not just integers) in an interval a to b with a < b, use the preceding algorithm, replacing the formula step 5 by
Let \[X_i = a + \frac{Y(b-a)}{d-1}\]
Generate 5000 Uniformly Distributed Rand. Real Numbers (not only integers)
Again, the histogram with 5000 real numbers shows a uniform random distribution with minimum value of -500 and maximum value of 500.
The density plot shows uniform probability of 0.001 as expected.
Two alternative designs are submitted for a NASA Mars landing module. Which design would you recommend?
What assumptions are required? Are the assumptions reasonable?
Each system can be evaluated by separating it into components, calculating each component’s reliability, then calculating the total system reliability.
\(A=0.993\)
\(B=R_1+R_2 - (R_1*R_2) = 0.995 + 0.995 -(0.995)^2 = 0.999975\)
\(C_1=L_{12}=L_1*L_2 = 0.99*0.999 = 0.98901\)
\(C=L_{12}+L_3 - (L_{12}*L_3)=L_{12}+0.998-(L_{12}*0.998)\)
\(C=0.98901+0.998-(0.98901*0.998)=0.99997802\)
\(D=0.98\)
\(E_1=0.99^2=0.9801\)
\(E_2=0.99^2=0.9801\)
\(E=E_1+E_2-(E_1*E_2)=0.9801+0.9801-0.96059601=0.99960399\)
Total System 1 Reliability = \(ABCDE=0.97270893\)
\(A=0.998\)
\(B=R_1+R_2 - (R_1*R_2) = 0.995 + 0.995 -(0.995)^2 = 0.999975\)
\(C=R_s=R_1+R_2+R_3-R_1R_2-R_1R_3-R_2R_3+R_1R_2R_3\)
\(C=0.99+0.999+0.998-(0.99*0.999)-(0.99*0.998)-\)
\((0.999*0.998)+(0.99*0.999*0.998)=0.99999998\)
\(D=0.98\)
\(E=1-(1-B_1)(1-B_2)(1-B_3)(1-B_4)=1-0.01^4=0.99999999\)
Total System 2 Reliability = \(ABCDE= 0.9780155\)
The second system has the higher reliability and would be recommended.
Practice Problems in Random Number Generation
Basics of Traditional Reliability
R Shiny Tutorial