Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Please answer this in Python:

There is no limit to the count of random numbers to be generated.

A common method of producing pseudo-random numbers is by means of the following recurrence relation:

R0 = seed value

Ri+1 = (a*Ri + c) % n where Ri denotes the ith pseudo-random number in the stream; a, c, and n are constant integers, and seed value is some initial value provided by the user or chosen automatically by the system.

Define a function that returns a stream of random numbers that uses this linear-congruential formula.

from operator import add, mul, mod

def make_random_stream(seed, a, c, n):

"""The infinite stream of pseudo-random numbers generated by the recurrence r[0] = SEED, r[i+1] = (r[i] * A + C) % N. Your solution must not use any lambdas or def's that we have not supplied in the skeleton.

>>> s = make_random_stream(25, 29, 5, 32)

>>> stream_to_list(s, 10) [25, 26, 23, 0, 5, 22, 3, 28, 17, 18]

>>> s = make_random_stream(17, 299317, 13, 2**20)

>>> stream_to_list(s, 10) [17, 894098, 115783, 383424, 775373, 994174, 941859, 558412, 238793, 718506]

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93081552

Have any Question?


Related Questions in Computer Engineering

What service is defined as it services for example in a gym

What service is defined as IT services? For example, in a gym, is members called IT services? What else? could you give me another example?

Question which register is allowed to be used as a pointer

Question : Which register Is allowed to be used as a pointer for register indirect addressing when accessing data stored in program ROM? Give the name and show how it is used Write a program that will read the following ...

Suppose mpc is 07 government spending increases by 10

Suppose MPC is 0.7. Government spending increases by $10 billion, and taxes decrease by $5 billion. How would the following items change, and by how much? Disposable income Private saving Public( Government) saving Equil ...

Question a show the results of inserting 10 12 1 14 6 5 8

Question : a) Show the results of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a into an initially empty binary heap. Show the tree at each stage. b) Show the result of performing three DeleteM ...

What is marketing discipline what is most peoples

What is marketing discipline? What is most people's perception of marketing discipline? Name an organization that has done a great job marketing. What did they do to make you feel this way?

Question need two different postsresponses with 200 words

Question: Need two different posts(responses) with 200 words each. After reviewing the assigned reading materials, complete the following activities: 1. Develop a product service idea. A. Describe the product/service inc ...

A simple repetitive song with varying verse the ants go

A simple repetitive song with varying verse, "The Ants Go Marching" provides a simple assignment for remembering the basic Control Structures - loops, switch statements, if-then-else statements, etc., that you learned in ...

Access your browsers security settings and configure the

Access your browser's security settings and configure the browser to refuse all cookies or to prompt you before allowing a cookie. Restart the browser; then visit several different Web sites. Be sure to visit popular sit ...

Question a swimmer is an athlete any athlete who

Question : A swimmer is an athlete. Any athlete, who participatedin the 2016 Summer Olympics and won a gold medal, was joyful. Any athlete, who is the world top athlete or a selected well-trained athlete, participatedin ...

The gravitational attraction between any two objects in the

The gravitational attraction between any two objects in the universe is given by the following formula: Force of Gravity = (G * m * n) / r 2 Where  m  and  n  are masses of the objects in kilograms,  r  is the distance b ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As