提交 c9dd94b8 authored 作者: Rémi Louf's avatar Rémi Louf 提交者: Brandon T. Willard

Add docstring for `TriangularRV`

上级 d6978bda
......@@ -116,12 +116,51 @@ uniform = UniformRV()
class TriangularRV(RandomVariable):
r"""A triangular continuous random variable.
The probability density function for `triangular` within the interval :math:`[l, r)`
and mode :math:`m` (where the peak of the distribution occurs) is:
.. math::
\begin{split}
f(x; l, m, r) = \begin{cases}
\frac{2(x-l)}{(r-l)(m-l)}\quad \text{for $l \leq x \leq m$},\\
\frac{2(r-x)}{(r-l)(r-m)}\quad \text{for $m \leq x \leq r$},\\
0\quad \text{otherwise}.
\end{cases}
\end{split}
"""
name = "triangular"
ndim_supp = 0
ndims_params = [0, 0, 0]
dtype = "floatX"
_print_name = ("Triang", "\\operatorname{Triang}")
def __call__(self, left, mode, right, size=None, **kwargs):
r"""Draw samples from a triangular distribution.
Parameters
----------
left
Lower boundary :math:`l` of the output interval; all values generated
will be greater than or equal to `left`.
mode
Mode :math:`m` of the distribution, where the peak occurs. Must be such
that `left <= mode <= right`.
right
Upper boundary :math:`r` of the output interval; all values generated
will be less than or equal to `right`. Must be larger than `left`.
size
Sample shape. If the given size is, e.g. `(m, n, k)` then `m * n * k`
independent, identically distributed random variables are
returned. Default is `None` in which case a single random variable
is returned.
"""
return super().__call__(left, mode, right, size=size, **kwargs)
triangular = TriangularRV()
......
......@@ -52,6 +52,9 @@ Aesara can produce :class:`RandomVariable`\s that draw samples from many differe
.. autoclass:: aesara.tensor.random.basic.UniformRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.TriangularRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.GammaRV
:members: __call__
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论