Boost logo

Boost Users :

Subject: [Boost-users] Boost random not looking so random
From: Robin Rowe (robin_at_[hidden])
Date: 2012-10-28 00:30:45


I'm using boost to shuffle an array, but it's not looking as random as I
would expect. Am I not using it right?

The code below outputs sequences that look random mostly, but I see
patterns such as 7 7 12 12 11.

        boost::random::mt19937 rng;
        boost::minstd_rand lcggen;
        lcggen.seed(clockTime);
        rng.seed(lcggen);
        unsigned min=1;
        unsigned max=15;
        for(unsigned i=0;i<5;i++)
        { boost::random::uniform_int_distribution<> dist(min,max);
                const int j = dist(rng);
                ... code that shuffles stuff using j ...
                min++;
                cout<<j<<' ';
        }

Suggestions?

Thanks!

Robin

--
www.cinepaint.org

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net