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 | None) – 可选,指定结果形状的非负整数元组。必须与 leftmoderight 广播兼容。默认值 (None) 生成的结果形状等于 left.shapemode.shaperight.shape

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

返回:

一个随机数组,具有指定的 dtype 和形状,如果 shape 不是 None,则形状由 shape 给定,否则由 left.shapemode.shaperight.shape 给定。

返回类型:

Array