Yaroslav Halchenko <[email protected]> wrote: > R, Python std library, numpy all have Mersenne Twister RNG implementation. > But > all of them generate different numbers. This issue was previously discussed > in > https://github.com/numpy/numpy/issues/4530 : In Python, and numpy generated > numbers are based on using 53 bits of two 32 bit random integers generated by > the algorithm (see below). Upon my brief inspection, original 32bit numbers > are nohow available for access neither in NumPy nor in Python stdlib > implementation.
NumPy uses the Randomkit library. The source is here: https://github.com/numpy/numpy/tree/master/numpy/random/mtrand It very easy to modify to produce whatever result you want. You can build it separately from NumPy. RandomState.bytes and np.random.bytes gives you the original random bytes in little endian order. It basically calles rk_fill in Randomkit and then unpacks the 32 bit random integer into four bytes. Just view it as dtype='<u4' to see the original 32-bit unsigned integers: a = np.random.bytes(4*n).view(dtype='<u4') Sturla _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
