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

Add docstring for `ChoiceRV`

上级 6f42bc5f
......@@ -1672,6 +1672,8 @@ integers = IntegersRV()
class ChoiceRV(RandomVariable):
"""Randomly choose an element in a sequence."""
name = "choice"
ndim_supp = 0
ndims_params = [1, 1, 0]
......@@ -1689,7 +1691,22 @@ class ChoiceRV(RandomVariable):
return size
def __call__(self, a, size=None, replace=True, p=None, **kwargs):
r"""Generate a random sample from an array.
Parameters
----------
a
The array from which to randomly sample an element.
size
Sample shape. If the given size is `(m, n, k)`, then `m * n *
k` independent samples are returned. Default is `None`, in
which case a single sample is returned.
replace
When ``True``, sampling is performed with replacement.
p
The probabilities associated with each entry in `a`. If not
given, all elements have equal probability.
"""
a = as_tensor_variable(a, ndim=1)
if p is None:
......
......@@ -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.ChoiceRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.BernoulliRV
:members: __call__
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论