|
Boost : |
Subject: Re: [boost] [random] seeding with arbitrary integers
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-10-21 14:05:41
Steven Watanabe wrote:
> This is only a major problem if you explicitly pass the seed:
> boost::minstd_rand gen(42);
can't this the be trapped and an an exception thrown?
> If the seed comes from somewhere else:
> boost::minstd_rand gen(time(0));
> then either the library or the user has to fix it up.
>
> Currently, the statement
> boost::minstd_rand gen(time(0));
> will work almost all the time.
>
> However, it is wrong because it will fail
> when time(0) returns 2147483647.
again, can't this be trapped?
>
> Is it worse to fix things up and possibly have
> multiple seeds yield that same sequence or
> to let code like this fail randomly once in a
> while? It seems to me that this bug is likely
> to be harder to trace because it won't even
> be reproducible.
Isn't it possible trap the problem and throw an exception?
To summarize, I would like any library I use to either
work as advertised or notify me that it can't handle
the arguments. And I would like this notification to
be as soon as possible. If it can't do this, then how
can I know that my program will really work?
Robert Ramey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk