Boost logo

Boost :

Subject: [boost] [random] seeding with arbitrary integers
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-10-20 17:51:37


AMDG

Currently, some PRNGs cannot be seeded with certain values.
For example, the seed for linear_congruential cannot be
a multiple of the modulus if the offset is zero. lagged_fibonacci
also cannot be seeded with 0, because it uses minstd_rand0.
Since linear_congruential already tries to wrap the seed to fit
in the range, I'd like to change it so that any seed works.

The other generator that needs to be changed is linear_feedback_shift.
linear_feedback_shift cannot be seeded with a small integer.
What I've done is to add the minimum value to the seed, if
the seed is too small. I'm not sure that this is a good solution,
since this means that there are a few (and only a few) seeds
that result in identical generators. Thoughts? Would it be
better to wrap the values to make them fit in range instead?
At least this would be consistent with linear_congruential.

I've attached a patch with these changes and test cases.

See also: http://svn.boost.org/trac/boost/ticket/3516
which prompted this investigation.

In Christ,
Steven Watanabe




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