nbodykit.mpirng

Classes

MPIRandomState(comm, seed, size[, chunksize])

A Random number generator that is invariant against number of ranks, when the total size of random number requested is kept the same.

class nbodykit.mpirng.MPIRandomState(comm, seed, size, chunksize=100000)[source]

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 RNG.

The sampler methods are collective calls; multiple calls will return uncorrerlated results.

The result is only invariant under diif comm.size when allreduce(size) and chunksize are kept invariant.

Methods

choice(choices[, itemshape, replace, p])

Produce self.size choices, each of shape itemshape.

normal([loc, scale, itemshape, dtype])

Produce self.size normals, each of shape itemshape.

poisson(lam[, itemshape, dtype])

Produce self.size poissons, each of shape itemshape.

uniform([low, high, itemshape, dtype])

Produce self.size uniforms, each of shape itemshape.

choice(choices, itemshape=(), replace=True, p=None)[source]

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

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

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

poisson(lam, itemshape=(), dtype='f8')[source]

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

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

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