[pypy-issue] [issue1381] random() generator returning result outside the 0.0 .. 1.0 domain.
tracker at bugs.pypy.org
Fri Jan 25 18:50:22 CET 2013
klankschap <vm at klankschap.nl> added the comment:
On 25 Jan 2013, at 11:37, Amaury Forgeot d Arc wrote:
> Amaury Forgeot d Arc <amauryfa at gmail.com> added the comment:
>> With the jumpahead() , setstate() and getstate() you can keep independent
>> streams for each class for every unit.
>> But if there is a simpler (faster) way, please hint !
> Did you know you can create distinct random objects? They keep their own internal state.
> gen = random.Random()
> print gen.random()
yes i do.
But if you have to create multiple millions of instances, things do severely delay...
So the idea is to create instances of the different classes, give them their own Random() generator, and then use the getstate, jumpahead, setstate
to create adhoc sub sequences.
It works, but unfortunately due to an error somewhere with the jumpahead(), the random() returns values >= 1.0
PyPy bug tracker <tracker at bugs.pypy.org>
More information about the pypy-issue