[SciPy-dev] random seed in scipy.stats

Hoyt Koepke hoytak@gmail....
Sat Apr 19 17:48:13 CDT 2008


I may have missed something here, so I'll first ask: Is there a way to
specify a random number seed in scipy.stats?  I'm building a project
using it which requires exactly reproducible distribution samples, so
being able to specify a random seed is a must.

I've been looking around in the code, and I don't see a way to do it.
Even if it is there, it calls numpy.random directly, which would not
work reliably.

However, it seems that it'd be easy to add in by initializing a
RandomState object in the constructors of both rv_continuous and
rv_discrete, seeding it using an optional kw arg that defaults to
None.  All the code that currently draws samples from numpy.random
directly would then draw samples from this.  As far as I can see, this
wouldn't break backwards compatibility and would add in a useful
feature.  The only change (I think) would be to distributions.py.

Have I missed anything?  If this is acceptable, I'll gladly make the
change and post a diff and a unit test.


Hoyt Koepke
UBC Department of Computer Science

More information about the Scipy-dev mailing list