Question

Consider the above quadratic residue generator xn+1 = xn2 mod m with m = 4783 ×...

Consider the above quadratic residue generator xn+1 = xn2 mod m with m = 4783 × 4027. Write a program to generate pseudo-random numbers from this generator. Use this to determine the period of the generator starting with seed x0 = 196, and with seed x0 = 400?

Homework Answers

Answer #1

The R program is

x={}

x0 = 196# seed

x[1]=x0

m =4783*4027

k=1 # how many next random numbers you want

for(n in 1:k){

x[n+1] =(x[n]^2)%%m

}

x

[1]   196 38416

#The Output is Seed and next random numbers

x0 = 400 # seed

x[1]=x0

m =4783*4027

k=1 # how many next random numbers you wants

for(n in 1:k){

x[n+1] =(x[n]^2)%%m

}

x

[1]    400 160000

# The output is Seed and next random numbers

x={}
x0 = 196
x[1]=x0
m =4783*4027
k=10
for(n in 1:k){
x[n+1] =(x[n]^2)%%m
}
x

 [1]      196    38416 11942340   179421  6528630 11496859 16561776  4718361
 [9] 17746035  3406856   543841

x0 = 400
x[1]=x0
m =4783*4027
k=10
for(n in 1:k){
x[n+1] =(x[n]^2)%%m
}
x

[1]      400   160000  1943611 13179555  2320953  1741316 15551072  3530790
 [9] 12690106 11484744 14234586
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
27.2 Generate 15 numbers using a seed of x0 = 1 in the following generator: xn...
27.2 Generate 15 numbers using a seed of x0 = 1 in the following generator: xn = (5xn-1+ 1) mod16
27.2 Generate 15 numbers using a seed of x0 = 1 in the following generator: xn...
27.2 Generate 15 numbers using a seed of x0 = 1 in the following generator: xn = (5xn-1 + 1) mod16. Perform a K-S test and check whether the sequence passes the test at a 95% confidence level.
Consider m=24, i.e., Xn+1 =(aXn) mod 24. (Hint: This is a common case for a linear...
Consider m=24, i.e., Xn+1 =(aXn) mod 24. (Hint: This is a common case for a linear congruential algorithm when m is a power of 2.) What restrictions are required on the seed?
Consider the linear congruential algorithm with an additive component of 0, i.e., Xn+1 =(aXn) mod m...
Consider the linear congruential algorithm with an additive component of 0, i.e., Xn+1 =(aXn) mod m a. It can be shown that if m is prime and if a given value of a produces the maximum period of m-1, then akwill also produce the maximum period, provided that k is less than m and that k and m-1 are relatively prime. Demonstrate this by using X0=1 and m=31 and producing the sequences for ak = 3, 32, 33, and 34.
Consider m=24, i.e., Xn+1 =(aXn) mod 24. (Hint: This is a common case for a linear...
Consider m=24, i.e., Xn+1 =(aXn) mod 24. (Hint: This is a common case for a linear congruential algorithm when m is a power of 2.) What should be the value of a to achieve the maximum period?
1) Consider a linear congruential random number generator with parameters a = 35, c = 20...
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. Consider the Markov chain {Xn|n ≥ 0} associated with Gambler’s ruin with m = 3....
1. Consider the Markov chain {Xn|n ≥ 0} associated with Gambler’s ruin with m = 3. Find the probability of ruin given X0 = i ∈ {0, 1, 2, 3} 2 Let {Xn|n ≥ 0} be a simple random walk on an undirected graph (V, E) where V = {1, 2, 3, 4, 5, 6, 7} and E = {{1, 2}, {1, 3}, {1, 6}, {2, 4}, {4, 6}, {3, 5}, {5, 7}}. Let X0 ∼ µ0 where µ0({i}) =...
/************************************************************************************* Function Prototypes *************************************************************************************/ int ScanArray(char *fname, int myArray[], int nSize); void Ge
/************************************************************************************* Function Prototypes *************************************************************************************/ int ScanArray(char *fname, int myArray[], int nSize); void GenerateFromArray(void); /************************************************************************************/ /************************************************************************************/ int main(void) { /* This is the main() program. It should call the functions ScanArray() and GenerateFromArray() */ GenerateFromArray(); system("pause"); return 0; } /*************************************************************************************** Define this function to scan the elements of an array from the given data file "ArrayInp.dat". If the input file is not found, or contains invalid data, the function should return a 0 and print an error message. If the input...
Part 1: Determine what is wrong (if any) with the following statements int A[4] = {...
Part 1: Determine what is wrong (if any) with the following statements int A[4] = { 1, 2, 3, 4, 5}; int A[4] = {1,2}; int A[4] = [1,2,3,4]; Part 2: Create one dimensional array and save the following integers in it:  2, 3, 6, 7, 10, 12. Display the values on the screen. (for example, a[0] = 2, a[1] = 3, etc.) Part 3: Write a program to read 5 integers from the user. Save these integers in an array...
Consider a satellite of mass m in a circular orbit of radius r around the Earth...
Consider a satellite of mass m in a circular orbit of radius r around the Earth of mass ME and radius RE. 1. What is the gravitational force (magnitude and direction) on the satellite from Earth? 2. If we define g(r) to be the force of gravity on a mass m at a radial distance r from the center of the Earth, divided by the mass m, then evaluate the ratio g(r)/g(RE)to see how g varies with radial distance. If...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT