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

Add docstring for `BernoulliRV`

上级 1dddad54
......@@ -1221,12 +1221,46 @@ truncexpon = TruncExponentialRV()
class BernoulliRV(ScipyRandomVariable):
r"""A Bernoulli discrete random variable.
The probability mass function for `bernoulli` in terms of the probability
of success :math:`p` of a single trial is:
.. math::
\begin{split}
f(k; p) = \begin{cases}
(1-p)\quad \text{if $k = 0$},\\
p\quad \text{if $k=1$}\\
\end{cases}
\end{split}
where :math:`0 \leq p \leq 1`.
"""
name = "bernoulli"
ndim_supp = 0
ndims_params = [0]
dtype = "int64"
_print_name = ("Bern", "\\operatorname{Bern}")
def __call__(self, p, size=None, **kwargs):
r"""Draw samples from a Bernoulli distribution.
Parameters
----------
p
Probability of success :math:`p` of a single trial.
size
Sample shape. If the given size is `(m, n, k)`, then `m * n * k`
independent, identically distributed samples are
returned. Default is `None` in which case a single sample
is returned.
"""
return super().__call__(p, size=size, **kwargs)
@classmethod
def rng_fn_scipy(cls, rng, p, size):
return stats.bernoulli.rvs(p, size=size, random_state=rng)
......
......@@ -49,6 +49,9 @@ Distributions
Aesara can produce :class:`RandomVariable`\s that draw samples from many different statistical distributions, using the following :class:`Op`\s.
.. autoclass:: aesara.tensor.random.basic.BernoulliRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.BetaRV
:members: __call__
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论