2022/10/20 11:52 (5) IEOR E4404 001 – Ed Lessons
View options
Show slides Show questions Show responses
Submitted Saved
Copyright By PowCoder代写 加微信 powcoder
Similar to how LCG generates a xed stream of random numbers given a xed x0 [assuming a, m, c are xed]. Mersenne Twister will give a xed stream of random numbers given a starting point of Random State. This RandomState will evolve every time a random number is generated (just like how x evolves). A RandomState contains the following information.
the string ‘MT19937’, specifying the Mersenne Twister algorithm.
a 1-D array of 624 unsigned 32-bit integers keys .
an integer pos .
an integer has_gauss .
a oat cached_gaussian .
In the previous cell, the rst time np.random.rand() is called, a Random State will be created and used to generate the rst random number. Throughout the cell, this Random State then updated to the next RandomState in a deterministic way whenever a random number is generated.
We can use get_state() to check what is stored in a state.
IEOR E4404 001 – Ed Lessons
Discussion is set to require approval for new threads
5 J Download PDF
import numpy as np
#generate one random number
print(np.random.rand())
#generate an array with 1 random number
print(np.random.rand(1))
#generate an array with 10 random numbers
print(np.random.rand(10))
#generate an array with 3 rows and *2 columns
print(np.random.rand(3,2))
import numpy as np
np.random.rand()
print(np.random.get_state())
https://edstem.org/us/courses/25500/lessons/42343/preview
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com