Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer this 5. Random number generators are important in numerical applications. One of the simpler methods is called the linear congruential method. Here, starting
Please answer this
5. Random number generators are important in numerical applications. One of the simpler methods is called the linear congruential method. Here, starting with some initial number Xo (which is called the seed) and constants a, c and m, with all numbers non-negative integers, we can generate a sequence Xn+1 = (aXn+c) mod m Here, mod is the modulus or remainder operator, which in C++ is $. Obviously this generates a deterministic sequence, but for good choices of a, c and m the sequence looks like random integers between 0 and m- 1. One possible choice is m = 134456, a = 8121, c = 28411. Write a function int randlc(const int x) that uses these constants and does a single update of the sequence, so the function argument is Xn and the returned value is Xn+1. For some large N, e.g. 10,000, and some positive integer choice for Xo, use the function randlc to fill in a vectorStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started