Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m=2**32
- def seed2(seed, a, b, m):
- # this function will remember the values of a, b, m, seed between the calls
- # it is called "closure"; feel free to read more about it, but this is not necessary for the course
- def lcg():
- nonlocal a, b, m, seed
- seed = (seed*a + b) % m
- return seed
- return lcg
- N = 10000
- K=100
- rand = seed2(1, a=1664525, b=1013904223, m=2**32)
- # allocate memory for N integer numbers
- arr = np.zeros(N, dtype=int)
- # fill with N random integers
- for i in range(N):
- arr[i] = rand();
Advertisement
Add Comment
Please, Sign In to add comment