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
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to