[Numpy-discussion] random number genration
Sturla Molden
sturla@molden...
Tue Mar 29 09:49:05 CDT 2011
Den 29.03.2011 15:46, skrev Daniel Lepage:
>
> x = (np.random.random(size)< p)
This will not work. A boolean array is not compactly stored, but an
array of bytes. Only the first bit 0 is 1 with probability p, bits 1 to
7 bits are 1 with probability 0. We thus have to do this 8 times for
each byte, shift left by range(8), and combine them with binary or.
Also the main use of random bits is crypto, which requires the use of
/dev/urandom or CrypGenRandom instead of Mersenne Twister (np.random.rand).
Sturla
More information about the NumPy-Discussion
mailing list