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

Add docstring for `MultinomialRV`

上级 3d796783
......@@ -1522,20 +1522,50 @@ gengamma = GenGammaRV()
class MultinomialRV(RandomVariable):
"""A Multinomial random variable type.
r"""A multinomial discrete random variable.
The probability mass function of `multinomial` in terms of the number
of experiments :math:`n` and the probabilities :math:`p_1, \dots, p_k`
of the :math:`k` different possible outcomes is:
.. math::
f(x_1,\dots,x_k; n, p_1, \dots, p_k) = \frac{n!}{x_1! \dots x_k!} \prod_{i=1}^k x_i^{p_i}
where :math:`n>0` and :math:`\sum_{i=1}^k p_i = 1`.
Notes
-----
The length of the support dimension is determined by the last
dimension in the *second* parameter (i.e. the probabilities vector).
"""
"""
name = "multinomial"
ndim_supp = 1
ndims_params = [0, 1]
dtype = "int64"
_print_name = ("MN", "\\operatorname{MN}")
def __call__(self, n, p, size=None, **kwargs):
r"""Draw samples from a discrete multinomial distribution.
Parameters
----------
n
Number of experiments :math:`n`. Must be a positive integer.
p
Probabilities of each of the :math:`k` different outcomes.
size
Given a size of, for example, `(r, s, t)`, `r * s * t` independent,
identically distributed samples are generated. Because each sample
is `k`-dimensional, the output shape is `(r, s, t, k)`. If no shape
is specified, a single `k`-dimensional sample is returned.
"""
return super().__call__(n, p, size=size, **kwargs)
def _supp_shape_from_params(self, dist_params, rep_param_idx=1, param_shapes=None):
return default_supp_shape_from_params(
self.ndim_supp, dist_params, rep_param_idx, param_shapes
......
......@@ -106,6 +106,9 @@ Aesara can produce :class:`RandomVariable`\s that draw samples from many differe
.. autoclass:: aesara.tensor.random.basic.LogNormalRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.MultinomialRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.MvNormalRV
:members: __call__
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论