Chapter 8: Problem 19
Diffcrcncc cquation for nandom numbcrs. Simple random number generators are based on simulating difference equations. Here is a typical set of two equations: $$ \begin{aligned} &x_{n}=\left(a x_{n-1}+c\right) \bmod m \\ &y_{n}=x_{n} / m \end{aligned} $$ for \(n=1,2, \ldots .\) A seed \(x_{0}\) must be given to start the sequence. The numbers \(y_{1}, y_{2}, \ldots\), represent the random numbers and \(x_{0}, x_{1}, \ldots\) are "help" numbers. Although \(y_{n}\) is completely deterministic from (8.14)(8.15), the sequence \(y_{n}\) appears random. The mathematical expression \(p\) mod \(q\) is coded as \(p \%\) q in Python. Use \(a=8121, c=28411\), and \(m=134456 .\) Solve the system \((8.14)-\) (8.15) in a function that generates and returns \(N\) random numbers. Make a histogram to examine the distribution of the numbers (the \(y_{n}\) numbers are randomly distributed if the histogram is approximately flat). Name of program file: diffeq_random.py.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.