On Sun 14/11/10 00:32 , Alex Hagen-Zanker ahh34@cam.ac.uk sent:
> I'm using mt19937 random number generator, belonging to Boost.Random
>library, and it looks to ignore my call to seed.
> I show relevant code.
>
> static mt19937 gen;
> static MiniUni cien(1, 100);
> static variate_generator d100(gen, cien);
>
> int main() {
> {
> struct timeval time;
> gettimeofday(
> gen.seed(time.tv_usec);
> }
>
> And it generates the same sequence over and over. I've double-checked
>that time.tv_usec really changes.

Could it be that variate_generator d100(gen, cien) defaults to
variate_generator d100(gen,cien) whereas you really need
variate_generator d100(gen,cien)?

The constructor of the variate_generator now makes a copy of gen and
changing the seed of gen afterwards does not affect the variate_generator.

Solution: explicitly use variate_generator(gen,cien).

Kind regards, Alex

You're completely right. It works now.
Thanks a lot!

Juan

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users">http://lists.boost.org/mailman/listinfo.cgi/boost-users