root / Pi / RNG / MWC.py @ 310
Historique | Voir | Annoter | Télécharger (403 octet)
| 1 |
#!/usr/bin/env python
|
|---|---|
| 2 |
|
| 3 |
import numpy |
| 4 |
|
| 5 |
SIZE=256
|
| 6 |
|
| 7 |
if __name__=='__main__': |
| 8 |
|
| 9 |
z=numpy.uint32(37)
|
| 10 |
w=numpy.uint32(91)
|
| 11 |
|
| 12 |
for i in range(1000): |
| 13 |
|
| 14 |
z=numpy.uint32(36969*(z&65535)+(z>>16)) |
| 15 |
w=numpy.uint32(18000*(w&65535)+(w>>16)) |
| 16 |
MWC= lambda : numpy.uint32((z<<16)+w) |
| 17 |
MWCfp= lambda: (MWC() + 1.0) * 2.328306435454494e-10 |
| 18 |
|
| 19 |
print i,MWC(),numpy.uint32(MWCfp()*SIZE)
|
| 20 |
|
| 21 |
|
| 22 |
|