[pypy-dev] random numbers

Floris van Manen vm at klankschap.nl
Sat Mar 7 21:06:13 CET 2015


Matti,

> On 7 Mar 2015, at 19:37, Matti Picus <matti.picus at gmail.com> wrote:
> 
> '''
> jumpahead(self, n) method of random.Random instance
>    Change the internal state to one that is likely far away
>    from the current state.  This method will not be in Py3.x,
>    so it is better to simply reseed.
> '''

Thanks for pointing out.

I'm using the jumpahead() to have multiple streams in parallel, derived from a single point.

def jumpRandomState(self):
    self.random.setstate(self.randomState)
    self.random.jumpahead(1)
    self.randomState = self.random.getstate()


Would this be a good alternative?

def jumpRandomState(self):
    self.random.setstate(self.randomState)
    self.random.seed(self.random.random())
    self.randomState = self.random.getstate()


.Floris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20150307/c2346d07/attachment.html>


More information about the pypy-dev mailing list