Guest User

Untitled

a guest
Jan 21st, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. m=2**32
  2. def seed2(seed, a, b, m):
  3.     # this function will remember the values of a, b, m, seed between the calls
  4.     # it is called "closure"; feel free to read more about it, but this is not necessary for the course
  5.     def lcg():
  6.         nonlocal a, b, m, seed
  7.         seed = (seed*a + b) % m
  8.         return seed
  9.     return lcg
  10. N = 10000
  11. K=100
  12.  
  13. rand = seed2(1, a=1664525, b=1013904223, m=2**32)
  14. # allocate memory for N integer numbers
  15. arr = np.zeros(N, dtype=int)
  16. # fill with N random integers
  17. for i in range(N):
  18.     arr[i] = rand();
Advertisement
Add Comment
Please, Sign In to add comment