Boost logo

Boost :

Subject: Re: [boost] Random numbers question
From: Anant Rao (arao_at_[hidden])
Date: 2009-07-24 21:00:35


Steven,
You're right... using the sample you sent, I get the same results on both Windows and Linux.

The numbers from my app on Windows match with your sample output. So, something is amiss on Linux, though it's exactly the same code on both Linux and Windows.

I'm scratching my head ...

-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Steven Watanabe
Sent: Friday, July 24, 2009 4:40 PM
To: boost_at_[hidden]
Subject: Re: [boost] Random numbers question

AMDG

Anant Rao wrote:
> I'm using Mersenne Twister algo to generate random numbers on Windows and Linux using the same code. Boost ver 1.39.
>
> Here's the simple code I have:
>
> boost::mt19937 rng(43);
> boost::uniform_01<boost::mt19937> zeroone(rng);
>
> float randomNumber = zeroone();
>
>
> If I run it multiple times, I get the same result on the same OS, as expected. However, the random numebrs are different between Windows and Linux.
>
> Is this the expected behavior? Is there anything I can do to get the same random numbers on Windowd and Linux?
>

Can you post complete code along with the output.
I get the same results from msvc and gcc from this program.

#include <boost/random/uniform_01.hpp>
#include <boost/random/mersenne_twister.hpp>

int main() {
    boost::mt19937 rng(43);
    boost::uniform_01<boost::mt19937> zeroone(rng);

    for(int i = 0; i < 10; ++i) {
        float randomNumber = zeroone();
        std::cout << randomNumber << std::endl;
    }
}

0.115055
0.496861
0.609067
0.102915
0.133391
0.148773
0.24059
0.172133
0.327139
0.811036

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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