Boost logo

Boost :

Subject: Re: [boost] [Random] reproducing numbers generated by R.
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-08-05 16:32:07


AMDG

Ronan Trépos wrote:
> For validity concerns, I'm trying to reproduce pseudo random numbers
> generated by the sofware R with boost::random library.
> The R default number generator is the Mersenne-Twister with period
> 2^19937 -1 .
>
> 1. In R I tried :
>
> > set.seed(13)
> > runif(1)
>
> 0.7103224
>
> 2. With boost I tried :
>
> boost::mt19937 rng(13);
> boost::uniform_01<boost::mt19937> zeroone(rng);
> std::cout << zeroone() << std::endl;
>
> 0.777702
>
> Has someone already experienced that ? Is it possible to reproduce the
> same numbers ?
> Maybe the mismatch comes from the fact that generated integers are
> translated into [0;1)..

I don't think so. I think the difference is that R uses its own
seeding algorithm.

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk