7. utils¶
7.1. pseudo_uniform¶
Lehmer random number generator, follwoing MINSTD.
Python | Julia |
---|---|
1U = np.zeros(size, dtype=complex)
2mult = 48271
3mod = (2**31) - 1
4x = (seed * mult + 1) % mod
5for i in range(size[0]):
6 for j in range(size[1]):
7 x = (x * mult + 1) % mod
8 U[i, j] = x / mod
9return U
| 1U = zeros(ComplexF64, size)
2mult = 48271
3mod = (2^31) - 1
4x = (seed * mult + 1) % mod
5for i = 1:size[1]
6 for j = 1:size[2]
7 x = (x * mult + 1) % mod
8 U[i, j] = x / mod
9 end
10end
11return U
|