jax.random.triangular#
- jax.random.triangular(key, left, mode, right, shape=None, dtype=<class 'float'>)[source]#
使用给定的形状和浮点数 dtype 采样三角随机值。
这些值根据概率密度函数返回
\[\begin{split}f(x; a, b, c) = \frac{2}{c-a} \left\{ \begin{array}{ll} \frac{x-a}{b-a} & a \leq x \leq b \\ \frac{c-x}{c-b} & b \leq x \leq c \end{array} \right.\end{split}\]在域 \(a \leq x \leq c\) 上。
- 参数:
key (ArrayLike) – 用作随机密钥的 PRNG 密钥。
left (RealArray) – 一个浮点数或与
shape
广播兼容的浮点数数组,表示分布的下限参数。mode (RealArray) – 一个浮点数或与
shape
广播兼容的浮点数数组,表示分布的峰值参数,该值必须满足条件left <= mode <= right
。right (RealArray) – 一个浮点数或与
shape
广播兼容的浮点数数组,表示分布的上限参数,必须大于left
。shape (Shape | None) – 可选,一个非负整数元组,指定结果形状。必须与
left
、``mode`` 和right
广播兼容。默认值 (None) 生成的结果形状等于left.shape
、mode.shape
和right.shape
。dtype (DTypeLikeFloat) – 可选,返回值的浮点数 dtype(如果 jax_enable_x64 为 true,则默认为 float64,否则为 float32)。
- 返回:
具有指定 dtype 的随机数组,其形状由
shape
给出(如果shape
不是 None),否则由left.shape
、mode.shape
和right.shape
给出。- 返回类型: