[Numpy-discussion] numpy.random and multiprocessing

David Cournapeau cournape@gmail....
Thu Dec 11 12:34:01 CST 2008


On Fri, Dec 12, 2008 at 2:49 AM, Gael Varoquaux
<gael.varoquaux@normalesup.org> wrote:
> On Fri, Dec 12, 2008 at 02:29:55AM +0900, David Cournapeau wrote:
>> The seed could be explicitly set in each task, no ?
>
>> def task(x):
>>     np.random.seed()
>>     return np.random.random(x)
>
> Yes. The problem is trivial to solve, once you are aware of it. Just like
> the integer division problems we used to have back in the days where
> zeros, ones, ... returned ineger arrays. The point is that people will
> run into that problem and loose a lot of time. So we must make it so that
> they don't by mistake land in this situation, but purposely.
>
> One solution is to check the PID of the process when the PRNG is called,
> and reseed if it has changed. As pointed out, the danger of this is that
> this is magic, so there needs to be an option to turn this off.

The biggest danger is that the whole method may not make sense at all,
and lose all the properties of a good random number generator. I don't
understand your comparison with integer division: this is not an API
or expected behavior problem, but an algorithmic one.

David


More information about the Numpy-discussion mailing list