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.

See also

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

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

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

See also

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

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.

See also

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

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

Returns an array of samples drawn from a exponential distribution.

See also

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

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.

See also

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

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()

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

Returns an array of samples drawn from the hypergeometric distribution.

See also

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

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

Returns an array of samples drawn from the laplace distribution.

See also

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

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

Returns an array of samples drawn from the logistic distribution.

See also

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

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

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

See also

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

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

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

See also

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

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.

See also

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

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

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

See also

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

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

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

See also

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

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

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

See also

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

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(a)[source]

Returns a permuted range or a permutation of an array.

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

Returns an array of samples drawn from the poisson distribution.

See also

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

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

Returns an array of samples drawn from the power distribution.

See also

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

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

See also

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

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

See also

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

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

Returns an array of samples drawn from a rayleigh distribution.

See also

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

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.

See also

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

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

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

See also

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

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

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

See also

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

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

Returns samples drawn from the standard normal distribution.

See also

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

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

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

See also

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

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

See also

numpy.random.RandomState.tomaxint()

triangular(left, mode, right, size=None, dtype=<class 'float'>)[source]

Returns an array of samples drawn from the triangular distribution.

See also

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

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

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

See also

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

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

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

See also

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

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

Returns an array of samples drawn from the Wald distribution.

See also

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

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

Returns an array of samples drawn from the weibull distribution.

See also

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

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()