Using the Linear Congruential Generator (LCG) with a=67, m=31, c=17 and seed Z0 = 117generate the first FIVE random variates on [0,1]. (6 Marks)
Question
Using the Linear Congruential Generator (LCG) with a=67, m=31, c=17 and seed Z0 = 117generate the first FIVE random variates on [0,1]. (6 Marks)
Solution
The Linear Congruential Generator (LCG) is a type of pseudorandom number generator. It is defined by the recurrence relation:
Zn+1 = (a*Zn + c) mod m
where:
- Zn is the sequence of pseudorandom values
- a, c, and m are generator-specific constants
- "mod" is the modulus operator
In this case, a=67, c=17, m=31, and the seed Z0=117.
Let's generate the first five random variates:
- Calculate Z1: Z1 = (aZ0 + c) mod m = (67117 + 17) mod 31 = 29
- Calculate Z2: Z2 = (aZ1 + c) mod m = (6729 + 17) mod 31 = 14
- Calculate Z3: Z3 = (aZ2 + c) mod m = (6714 + 17) mod 31 = 6
- Calculate Z4: Z4 = (aZ3 + c) mod m = (676 + 17) mod 31 = 27
- Calculate Z5: Z5 = (aZ4 + c) mod m = (6727 + 17) mod 31 = 23
Now, to convert these to the range [0,1], divide each by m:
- Z1/m = 29/31 = 0.9355
- Z2/m = 14/31 = 0.4516
- Z3/m = 6/31 = 0.1935
- Z4/m = 27/31 = 0.8710
- Z5/m = 23/31 = 0.7419
So, the first five random variates on [0,1] are 0.9355, 0.4516, 0.1935, 0.8710, and 0.7419.
Similar Questions
he parameters of the linear congruential generator xn+1 := axn(mod m), un := xnm are a :=numberof letters in your name, m := 2number of letters in your last name, x0 := number of letters in your nametotal number of letters in your name and last name .Compute the first 5 values of the sequence and discuss whether it is a good random number generatoror not. What deficiencies do you expect it will have?
Pseudorandom Number Generators
Which of the following options is the best for generating random integer 0 or 1?
A sequence of pseudo-random numbers are generated using xn+1 = (3xn + 5) mod 31 with seed x0 = 2. Find x1, x2, and x3.Select one:a.x1 = 11, x2 = 7, x3 = 26b.x1 = 11, x2 = 1, x3 = 8c.x1 = 8, x2 = 29, x3 = 30d.None of the otherse.x1 = 11, x2 = 7, x3 = 13Clear my choice
A sequence of pseudo-random numbers are generated using xn+1 = (3xn + 5) mod 31 with seed x0 = 2. Find x1, x2, and x3.Select one:a.x1 = 11, x2 = 7, x3 = 26b.x1 = 11, x2 = 1, x3 = 8c.x1 = 8, x2 = 29, x3 = 30d.None of the otherse.x1 = 11, x2 = 7, x3 = 13
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.