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.

See also

cupy.random.beta() for full documentation, numpy.random.RandomState.beta()

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.

See also

cupy.random.choice() for full document, numpy.random.choice()

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.

See also

cupy.random.f() for full documentation, numpy.random.RandomState.f()

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

Returns an array of samples drawn from a gamma distribution.

See also

cupy.random.gamma() for full documentation, numpy.random.RandomState.gamma()

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.

See also

cupy.random.gumbel() for full documentation, numpy.random.RandomState.gumbel()

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

Returns an array of samples drawn from the laplace 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.

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.

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

Returns an array of normally distributed samples.

See also

cupy.random.normal() for full documentation, numpy.random.RandomState.normal()

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

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

See also

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.

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

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

See also

cupy.random.rand() for full documentation, numpy.random.RandomState.rand()

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.

See also

cupy.random.randn() for full documentation, numpy.random.RandomState.randn()

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

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

seed(seed=None)[source]

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

See also

cupy.random.seed() for full documentation, numpy.random.RandomState.seed()

shuffle(a)[source]

Returns a shuffled array.

See also

cupy.random.shuffle() for full document, numpy.random.shuffle()

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.
Returns:Drawn samples.
Return type:cupy.ndarray
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.

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

Returns an array of samples drawn from the Zipf distribution.

See also

cupy.random.zipf() for full documentation, numpy.random.RandomState.zipf()