maxframe.tensor.random.wald#
- maxframe.tensor.random.wald(mean, scale, size=None, chunk_size=None, gpu=None, dtype=None)[源代码]#
从 Wald 分布(或逆高斯分布)中抽取样本。
当 scale 趋近于无穷大时,该分布越来越接近高斯分布。一些文献认为 Wald 分布是均值为 1 的逆高斯分布,但这并不具有普遍性。
逆高斯分布最初是在研究布朗运动时被引入的。1956 年,M.C.K. Tweedie 使用“逆高斯”这一名称,因为单位距离所需时间和单位时间内所走距离之间存在反比关系。
- 参数:
mean (float or array_like of floats) -- 分布的均值,应大于 0。
scale (float or array_like of floats) -- 尺度参数,应大于等于 0。
size (int or tuple of ints, optional) -- 输出形状。如果给定形状为
(m, n, k),则抽取m * n * k个样本。如果 size 为None``(默认),且 ``mean和scale均为标量,则返回单个值。否则,抽取np.broadcast(mean, scale).size个样本。chunk_size (int or tuple of int or tuple of ints, optional) -- 每个维度上期望的分块大小
gpu (bool, optional) -- 如果为 True,则将张量分配在 GPU 上,默认为 False
dtype (data-type, optional) -- 返回张量的数据类型。
- 返回:
out -- 从参数化的 Wald 分布中抽取的样本。
- 返回类型:
Tensor or scalar
备注
Wald 分布的概率密度函数为
\[P(x;mean,scale) = \sqrt{\frac{scale}{2\pi x^3}}e^ \frac{-scale(x-mean)^2}{2\cdotp mean^2x}\]如上所述,逆高斯分布最初源于对布朗运动的建模尝试。它也是 Weibull 分布在可靠性建模以及股票收益和利率过程建模中的竞争模型。
引用
示例
从分布中抽取值并绘制直方图:
>>> import matplotlib.pyplot as plt >>> import maxframe.tensor as mt >>> h = plt.hist(mt.random.wald(3, 2, 100000).execute(), bins=200, normed=True) >>> plt.show()