jax.random.loggamma#

jax.random.loggamma(key, a, shape=None, dtype=<class 'float'>)[source]#

使用给定形状和浮点数 dtype 采样 log-gamma 随机值。

此函数的实现方式应使以下内容在适用于 dtype 的容差范围内成立

np.testing.assert_allclose(jnp.exp(loggamma(*args)), gamma(*args), rtol=rtol)

log-gamma 的好处在于,对于非常接近于零的样本(当 a << 1 时经常发生),在对数空间中采样可提供更好的精度。

参数:
  • key (ArrayLike) – 用作随机密钥的 PRNG 密钥。

  • a (RealArray) – 一个浮点数或与 shape 广播兼容的浮点数数组,表示分布的参数。

  • shape (Shape | None) – 可选,一个非负整数元组,用于指定结果形状。 必须与 a 广播兼容。 默认值 (None) 生成一个等于 a.shape 的结果形状。

  • dtype (DTypeLikeFloat) – 可选,返回值的浮点数 dtype(如果 jax_enable_x64 为 true,则默认为 float64,否则为 float32)。

返回:

一个具有指定 dtype 的随机数组,其形状由 shape 给定(如果 shape 不为 None),否则由 a.shape 给定。

返回类型:

数组

另请参阅

gamma : 标准 gamma 采样器。