cupy.random.RandomState#

class cupy.random.RandomState(seed=None, method=None)[源代码][源代码]#

伪随机数生成器的可移植容器。

此类的一个实例保存了随机数生成器的状态。该状态仅在实例初始化时所在的设备上可用。

cupy.random 的函数使用此类型的全局实例。不同的设备使用不同的实例。可以通过 cupy.random.get_random_state() 函数获取当前设备的全局状态。

参数:
  • seed (None or int) – 随机数生成器的种子。详情请参见 seed() 方法。

  • method (int) –

    随机数生成器的方法。以下值可用:

    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
    

方法

beta(a, b, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从贝塔分布中抽取的样本数组。

参见

binomial(n, p, size=None, dtype=<class 'int'>)[源代码][源代码]#

返回从二项分布中抽取的样本数组。

参见

chisquare(df, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从卡方分布中抽取的样本数组。

参见

choice(a, size=None, replace=True, p=None)[源代码][源代码]#

返回从给定的一维数组中随机抽取的值的数组。

参见

dirichlet(alpha, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从狄利克雷分布中抽取的样本数组。

参见

exponential(scale=1.0, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从指数分布中抽取的样本数组。

警告

此功能可能会同步设备。

参见

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

返回从 f 分布中抽取的样本数组。

参见

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

返回从伽马分布中抽取的样本数组。

参见

geometric(p, size=None, dtype=<class 'int'>)[源代码][源代码]#

返回从几何分布中抽取的样本数组。

参见

gumbel(loc=0.0, scale=1.0, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从Gumbel分布中抽取的样本数组。

参见

hypergeometric(ngood, nbad, nsample, size=None, dtype=<class 'int'>)[源代码][源代码]#

返回从超几何分布中抽取的样本数组。

参见

laplace(loc=0.0, scale=1.0, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从拉普拉斯分布中抽取的样本数组。

参见

logistic(loc=0.0, scale=1.0, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从逻辑分布中抽取的样本数组。

参见

lognormal(mean=0.0, sigma=1.0, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从对数正态分布中抽取的样本数组。

参见

logseries(p, size=None, dtype=<class 'int'>)[源代码][源代码]#

返回从对数级数分布中抽取的样本数组。

警告

此功能可能会同步设备。

参见

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

返回从多元正态分布中抽取的样本数组。

警告

此函数调用一个或多个 cuSOLVER 例程,如果输入条件不满足,可能会产生无效结果。要检测这些无效结果,您可以在 cupyx.errstate()cupyx.seterr() 中将 linalg 配置设置为非 ignore 的值。

参见

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

返回从负二项分布中抽取的样本数组。

警告

此功能可能会同步设备。

参见

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

返回从非中心卡方分布中抽取的样本数组。

警告

此功能可能会同步设备。

参见

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

返回从非中心 F 分布中抽取的样本数组。

警告

此功能可能会同步设备。

参见

normal(loc=0.0, scale=1.0, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回一个正态分布样本的数组。

参见

pareto(a, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从帕累托 II 分布中抽取的样本数组。

参见

permutation(a)[源代码][源代码]#

返回一个排列的范围或数组的排列。

poisson(lam=1.0, size=None, dtype=<class 'int'>)[源代码][源代码]#

返回从泊松分布中抽取的样本数组。

参见

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

返回从幂分布中抽取的样本数组。

警告

此功能可能会同步设备。

参见

rand(*size, **kwarg)[源代码][源代码]#

返回区间 [0, 1) 上的均匀随机值。

参见

randint(low, high=None, size=None, dtype=<class 'int'>)[源代码][源代码]#

返回一个标量或一个整数值数组,范围在 [low, high) 之间。

参见

randn(*size, **kwarg)[源代码][源代码]#

返回一个标准正态随机值的数组。

参见

random_sample(size=None, dtype=<class 'float'>)[源代码][源代码]#

返回一个在区间 [0, 1) 内的随机值数组。

参见

rayleigh(scale=1.0, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从瑞利分布中抽取的样本数组。

警告

此功能可能会同步设备。

参见

seed(seed=None)[源代码][源代码]#

使用种子重置随机数生成器的状态。

参见

shuffle(a)[源代码][源代码]#

返回一个打乱顺序的数组。

参见

standard_cauchy(size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从标准柯西分布中抽取的样本数组。

参见

standard_exponential(size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从标准指数分布中抽取的样本数组。

参见

standard_gamma(shape, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从标准伽马分布中抽取的样本数组。

参见

standard_normal(size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从标准正态分布中抽取的样本。

参见

standard_t(df, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从标准 t 分布中抽取的样本数组。

参见

tomaxint(size=None)[源代码][源代码]#

绘制介于 0 和最大整数(包括)之间的整数。

返回在区间 [0, np.iinfo(np.int_).max] 内均匀分布的随机整数样本。np.int_ 类型转换为 C 长整型,其精度依赖于平台。

参数:

size (int or tuple of ints) – 输出形状。

返回:

绘制的样本。

返回类型:

cupy.ndarray

参见

numpy.random.RandomState.tomaxint()

triangular(left, mode, right, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从三角分布中抽取的样本数组。

警告

此功能可能会同步设备。

参见

uniform(low=0.0, high=1.0, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回一个在区间内均匀分布的样本数组。

参见

vonmises(mu, kappa, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从von Mises分布中抽取的样本数组。

参见

wald(mean, scale, size=None, dtype=<class 'float'>)[源代码][源代码]#

返回从Wald分布中抽取的样本数组。

参见

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

返回从韦伯分布中抽取的样本数组。

警告

此功能可能会同步设备。

参见

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

返回从Zipf分布中抽取的样本数组。

警告

此功能可能会同步设备。

参见

__eq__(value, /)#

返回 self==value。

__ne__(value, /)#

返回 self!=value。

__lt__(value, /)#

返回 self<value。

__le__(value, /)#

返回 self<=value。

__gt__(value, /)#

返回 self>value。

__ge__(value, /)#

返回 self>=value。