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

Add docstring for `CategoricalRV`

上级 6d276686
......@@ -1596,12 +1596,41 @@ vsearchsorted = np.vectorize(np.searchsorted, otypes=[int], signature="(n),()->(
class CategoricalRV(RandomVariable):
r"""A categorical discrete random variable.
The probability mass function of `categorical` in terms of its :math:`N` event
probabilities :math:`p_1, \dots, p_N` is:
.. math::
P(k=i) = p_k
where :math:`\sum_i p_i = 1`.
"""
name = "categorical"
ndim_supp = 0
ndims_params = [1]
dtype = "int64"
_print_name = ("Cat", "\\operatorname{Cat}")
def __call__(self, p, size=None, **kwargs):
r"""Draw samples from a discrete categorical distribution.
Parameters
----------
p
An array that contains the :math:`N` event probabilities.
size
Sample shape. If the given size is `(m, n, k)`, then `m * n * k`
independent, identically distributed random 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(cls, rng, p, size):
if size is None:
......
......@@ -76,6 +76,9 @@ Aesara can produce :class:`RandomVariable`\s that draw samples from many differe
.. autoclass:: aesara.tensor.random.basic.CauchyRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.CategoricalRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.ChiSquareRV
:members: __call__
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论