Boost logo

Boost :

Subject: Re: [boost] [random] seeding with arbitrary integers
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-10-22 13:24:49

John Maddock wrote:
>> seed will work as advertised. Regardless of the outcome
>> of this discussion, I will make sure that the exact behavior
>> is documented.
> I think that's the key here: if the documentation clearly states that
> the seed is treated modulo N or whatever then that would be OK for me.
> Whatever the status quo is unacceptable given that seeding with
> unspecified values (from time() or some other non-deterministic
> device) is so commonplace. Throwing an exception for out-of-range
> values might work, but as pointed out the exception would occur so
> infrequently in practice that your just creating another source of
> bugs.
> Robert, what if the docs clearly stated that "Safe values for the
> seed are 0-N, values outside this range get wrapped within it via
> modulo N arithmetic, therefore different seeds can result in the same
> sequence
> of random values if one of those seeds is outside of the safe range."
> Or something like that ;-)

Fine by me. In fact, all of you have considered it more than I
have so I'm very happy to defer to your judgment on this case.

I just reacted to the general idea of fixing stuff up under the covers.

It turns out that I just happened to need a quick and idiot-proof
number generator so I used boost.random.
I think the motivation for my original complaint was:
"uh - oh, do have actually have to know something about
random number generation to use this library?" If so, I've
got a problem. I want it to "just work". Being idiot-proof
was a pre-condition in this circumstance. I realize that
satisifying such a pre-condition is the motivation for the
proposed solution and I'm OK with that. But when this
is done "silently", it can create problems which are devilishly
hard to find.

Also, I found the documentation not good enough in general. I did
make it work but it wasn't as easy to use as I would have hoped.
Of course I could make the same criticism for many or most

Of course at the root of the problem is the desire to use
facilities that I have neither the knowledge nor time to implement
myself. But that's what I use libraries for - so they almost have
to be idiot proof to be useful to me.

Just one man's opinion.

Robert Ramey

Boost list run by bdawes at, gregod at, cpdaniel at, john at