cupy.random.RandomState¶

class cupy.random.RandomState(seed=None, method=100)[source]

Portable container of a pseudo-random number generator.

An instance of this class holds the state of a random number generator. The state is available only on the device which has been current at the initialization of the instance.

Functions of cupy.random use global instances of this class. Different instances are used for different devices. The global state for the current device can be obtained by the cupy.random.get_random_state() function.

Parameters: seed (None or int) – Seed of the random number generator. See the seed() method for detail. method (int) – Method of the random number generator. Following values are available: cupy.cuda.curand.CURAND_RNG_PSEUDO_DEFAULT cupy.cuda.curand.CURAND_RNG_XORWOW cupy.cuda.curand.CURAND_RNG_MRG32K3A cupy.cuda.curand.CURAND_RNG_MTGP32 cupy.cuda.curand.CURAND_RNG_MT19937 cupy.cuda.curand.CURAND_RNG_PHILOX4_32_10 

Methods

beta(a, b, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the beta distribution.

binomial(n, p, size=None, dtype=<class 'int'>)[source]

Returns an array of samples drawn from the binomial distribution.

chisquare(df, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the chi-square distribution.

choice(a, size=None, replace=True, p=None)[source]

Returns an array of random values from a given 1-D array.

dirichlet(alpha, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the dirichlet distribution.

exponential(scale=1.0, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from a exponential distribution.

f(dfnum, dfden, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the f distribution.

gamma(shape, scale=1.0, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from a gamma distribution.

geometric(p, size=None, dtype=<class 'int'>)[source]

Returns an array of samples drawn from the geometric distribution.

gumbel(loc=0.0, scale=1.0, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from a Gumbel distribution.

hypergeometric(ngood, nbad, nsample, size=None, dtype=<class 'int'>)[source]

Returns an array of samples drawn from the hypergeometric distribution.

laplace(loc=0.0, scale=1.0, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the laplace distribution.

logistic(loc=0.0, scale=1.0, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the logistic distribution.

lognormal(mean=0.0, sigma=1.0, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from a log normal distribution.

logseries(p, size=None, dtype=<class 'int'>)[source]

Returns an array of samples drawn from a log series distribution.

multivariate_normal(mean, cov, size=None, check_valid='ignore', tol=1e-08, dtype=<class 'float'>)[source]

(experimental) Returns an array of samples drawn from the multivariate normal distribution.

negative_binomial(n, p, size=None, dtype=<class 'int'>)[source]

Returns an array of samples drawn from the negative binomial distribution.

noncentral_chisquare(df, nonc, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the noncentral chi-square distribution.

noncentral_f(dfnum, dfden, nonc, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the noncentral F distribution.

normal(loc=0.0, scale=1.0, size=None, dtype=<class 'float'>)[source]

Returns an array of normally distributed samples.

pareto(a, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the pareto II distribution.

cupy.random.pareto_kernel() for full documentation, numpy.random.RandomState.pareto()

permutation(num)[source]

Returns a permuted range.

poisson(lam=1.0, size=None, dtype=<class 'int'>)[source]

Returns an array of samples drawn from the poisson distribution.

power(a, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the power distribution.

rand(*size, **kwarg)[source]

Returns uniform random values over the interval [0, 1).

randint(low, high=None, size=None, dtype='l')[source]

Returns a scalar or an array of integer values over [low, high).

randn(*size, **kwarg)[source]

Returns an array of standard normal random values.

random_sample(size=None, dtype=<class 'float'>)[source]

Returns an array of random values over the interval [0, 1).

rayleigh(scale=1.0, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from a rayleigh distribution.

seed(seed=None)[source]

Resets the state of the random number generator with a seed.

shuffle(a)[source]

Returns a shuffled array.

standard_cauchy(size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the standard cauchy distribution.

standard_exponential(size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the standard exp distribution.

standard_gamma(shape, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from a standard gamma distribution.

standard_normal(size=None, dtype=<class 'float'>)[source]

Returns samples drawn from the standard normal distribution.

standard_t(df, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the standard t distribution.

tomaxint(size=None)[source]

Draws integers between 0 and max integer inclusive.

Parameters: size (int or tuple of ints) – Output shape. Drawn samples. cupy.ndarray
triangular(left, mode, right, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the triangular distribution.

uniform(low=0.0, high=1.0, size=None, dtype=<class 'float'>)[source]

Returns an array of uniformly-distributed samples over an interval.

vonmises(mu, kappa, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the von Mises distribution.

wald(mean, scale, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the Wald distribution.

weibull(a, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the weibull distribution.

zipf(a, size=None, dtype=<class 'int'>)[source]

Returns an array of samples drawn from the Zipf distribution.