lib.mpi.MPIRandomState

class lib.mpi.MPIRandomState(size, seed=None, chunksize=100000, mpicomm=None)

Bases: object

A Random number generator that is invariant against number of ranks, when the total size of random number requested is kept the same. The algorithm here assumes the random number generator from numpy produces uncorrelated results when the seeds are sampled from a single random generator. The sampler methods are collective calls; multiple calls will return uncorrelated results. The result is only invariant under different mpicomm.size when mpicomm.allreduce(size) and chunksize are kept invariant.

Taken from https://github.com/bccp/nbodykit/blob/master/nbodykit/mpirng.py

Methods

normal

Produce size normals, each of shape itemshape.

poisson

Produce size poissons, each of shape itemshape.

uniform

Produce size uniforms, each of shape itemshape.

normal(loc=0, scale=1, itemshape=(), dtype='f8')

Produce size normals, each of shape itemshape. This is a collective MPI call.

poisson(lam, itemshape=(), dtype='f8')

Produce size poissons, each of shape itemshape. This is a collective MPI call.

uniform(low=0.0, high=1.0, itemshape=(), dtype='f8')

Produce size uniforms, each of shape itemshape. This is a collective MPI call.