cupy.random.RandomState#

class cupy.random.RandomState(seed=None, method=None)[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_PSEUDO_XORWOW
    cupy.cuda.curand.CURAND_RNG_PSEUDO_MRG32K3A
    cupy.cuda.curand.CURAND_RNG_PSEUDO_MTGP32
    cupy.cuda.curand.CURAND_RNG_PSEUDO_MT19937
    cupy.cuda.curand.CURAND_RNG_PSEUDO_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

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

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.

Warning

This function may synchronize the device.

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

Returns an array of samples drawn from the f distribution.

See also

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

Returns an array of samples drawn from a gamma distribution.

See also

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.

Warning

This function may synchronize the device.

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

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

Warning

This function calls one or more cuSOLVER routine(s) which may yield invalid results if input conditions are not met. To detect these invalid results, you can set the linalg configuration to a value that is not ignore in cupyx.errstate() or cupyx.seterr().

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

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

Warning

This function may synchronize the device.

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

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

Warning

This function may synchronize the device.

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

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

Warning

This function may synchronize the device.

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.

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.

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

Returns an array of samples drawn from the power distribution.

Warning

This function may synchronize the device.

See also

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

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

See also

randint(low, high=None, size=None, dtype=<class 'int'>)[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

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.

Warning

This function may synchronize the device.

seed(seed=None)[source]#

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

See also

shuffle(a)[source]#

Returns a shuffled array.

See also

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.

Return a sample of uniformly distributed random integers in the interval [0, np.iinfo(np.int_).max]. The np.int_ type translates to the C long integer type and its precision is platform dependent.

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.

Warning

This function may synchronize the device.

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.

See also

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

Returns an array of samples drawn from the weibull distribution.

Warning

This function may synchronize the device.

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

Returns an array of samples drawn from the Zipf distribution.

Warning

This function may synchronize the device.

See also

__eq__(value, /)#

Return self==value.

__ne__(value, /)#

Return self!=value.

__lt__(value, /)#

Return self<value.

__le__(value, /)#

Return self<=value.

__gt__(value, /)#

Return self>value.

__ge__(value, /)#

Return self>=value.