Define a function that returns a stream of random numbers

Assignment Help Computer Engineering
Reference no: EM132094081

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]

Reference no: EM132094081

Questions Cloud

Working mechanism of ransomware : Potential threats and mitigation tools for ransomware - Overview of Network Security - Analyse and discuss common emerging threats, attacks, mitigation
Cost benefit analysis template : Apply a cost-benefit analysis to consider potential profit and risks to your organization based on the experience of Banner Health System.
Perform an amortized analysis of the running time of n : Suppose that after every K operations, we automatically make a copy of the stack for back-up purposes. (Note the stack may or may not be full at this point.)
Immigration platforms of two organizations : Research and compare the immigration platforms of two organizations: one American political party
Define a function that returns a stream of random numbers : Define a function that returns a stream of random numbers that uses this linear-congruential formula.
What are the purposes of integration testing : What are the purposes of Integration testing and who needs to conduct Integration testing?
Light bulbs should be used to light a warehouse : A plant engineer wishes to know which of two types of light bulbs should be used to light a warehouse.
Research and development department : In the research and development department can you tell on what must i based myself when adjusting the size, performance and MTBF.
What was the most difficult part of locating quality : What was the most difficult part of locating quality sources on your topic in Module 6? What was the most rewarding?

Reviews

Write a Review

Computer Engineering Questions & Answers

  How would an attacker break a caesar-style cipher

What is the Caesar ROT3 Cipher? Although the Caesar cipher is easy to use, it is easy to crack. How would an attacker break a Caesar-style cipher?

  What is the final step in determining observability

What is the final step in determining observability if the observability matrix is a square matrix?

  Operation for circular linked list

Write down an algorithm or code segment for searching the circular linked list for a given item. Write down an algorithm or the code segment for locating nth successor of an item within a circular linked list (nth item which follows the given item ..

  Which programming languages are used in ajax applications

For what particular kind of Web application was Rails designed? Which programming languages are used in Ajax applications?

  Design a dedicated datapath for inputting three 8-bit

design a dedicated datapath for inputting three 8-bit unsigned numbers and then output the. largest number followed by

  I want design circuit this bufferlifo this blocking is for

i want design circuit this bufferlifo. this blocking is for fifo memory but i want design circuit buffer last-in

  Explain technology and information systems in apa style

express information technology and information systems in APA style and why is it important for a manager to be involved in IT and what are the critical responsibilities for the manager.

  Show the current selections made by the user

construct a program that demonstrates the enhanced options for the MessageBox class. Use three GroupBox controls with RadioButton controls contained within each.

  Describe both hardware and software tools

The development of a forensic lab for computers and mobile devices involves numerous specialized tools. Describe both hardware and software tools that might be.

  Compute the record size r in bytes

suppose the file is ordered by SSN; calculate the number of blocks it takes to search for a record given its SSN value by doing a binary search.

  Discuss management activities to monitor access control

Please discuss management actions and activities to monitor access control. In your answer, consider hardware, software, cloud-based applications.

  Questiontranslate following c program to pep8 assembly

questiontranslate following c program to pep8 assembly language-include ltiostreamgtusing namespace stdint myagevoid

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd