Re: [Numpy-discussion] match RNG numbers with R?

2014-04-07 Thread Sturla Molden
Yaroslav Halchenko li...@onerussian.com wrote: so I would assume that the devil is indeed in R post-processing and would look into it (if/when get a chance). I tried to look into the R source code. It's the worst mess I have ever seen. I couldn't even find their Mersenne twister. Sturla

Re: [Numpy-discussion] match RNG numbers with R?

2014-04-07 Thread Yaroslav Halchenko
On Mon, 07 Apr 2014, Sturla Molden wrote: so I would assume that the devil is indeed in R post-processing and would look into it (if/when get a chance). I tried to look into the R source code. It's the worst mess I have ever seen. I couldn't even find their Mersenne twister. it is in

Re: [Numpy-discussion] match RNG numbers with R?

2014-04-07 Thread Daπid
On Apr 7, 2014 3:59 AM, Yaroslav Halchenko li...@onerussian.com wrote: so I would assume that the devil is indeed in R post-processing and would look into it (if/when get a chance). The devil here is the pigeon and the holes problem. Mersenne Twister generates random integers in a certain

Re: [Numpy-discussion] match RNG numbers with R?

2014-04-07 Thread Robert Kern
On Mon, Apr 7, 2014 at 3:16 PM, Daπid davidmen...@gmail.com wrote: On Apr 7, 2014 3:59 AM, Yaroslav Halchenko li...@onerussian.com wrote: so I would assume that the devil is indeed in R post-processing and would look into it (if/when get a chance). The devil here is the pigeon and the holes

Re: [Numpy-discussion] match RNG numbers with R?

2014-04-07 Thread Sturla Molden
Yaroslav Halchenko li...@onerussian.com wrote: it is in src/main/RNG.c (ack is nice ;) )... from visual inspection looks matching I see... It's a rather vanilla Mersenne Twister, and it just use 32 bits of randomness. An signed int32 is multiplied by 2.3283064365386963e-10 to scale it to

[Numpy-discussion] match RNG numbers with R?

2014-04-06 Thread Yaroslav Halchenko
Hi NumPy gurus, We wanted to test some of our code by comparing to results of R implementation which provides bootstrapped results. R, Python std library, numpy all have Mersenne Twister RNG implementation. But all of them generate different numbers. This issue was previously discussed in

Re: [Numpy-discussion] match RNG numbers with R?

2014-04-06 Thread Sturla Molden
Yaroslav Halchenko li...@onerussian.com 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

Re: [Numpy-discussion] match RNG numbers with R?

2014-04-06 Thread Sturla Molden
a = np.random.bytes(4*n).view(dtype='u4') If you for example want a post-processing that just use 32 bits of randomness per deviate, you can e.g. do something like this: r = np.random.bytes(4*n).view(dtype='u4').astype(float)/float(0x+1) I have no idea what R does, though. NumPy's

Re: [Numpy-discussion] match RNG numbers with R?

2014-04-06 Thread Yaroslav Halchenko
On Sun, 06 Apr 2014, Sturla Molden 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