Skip to content

Commit

Permalink
[doc] clarify the range of sampled rv for torch.tensor.exponential_ (#…
Browse files Browse the repository at this point in the history
…113195)

Range of sampled random variable needs to be clarified for `torch.tensor.exponential_` whose supported interval is (0, inf) is different from [0, inf] of exponential distribution.

Background: #37984 (comment), #48841 (comment), #91673 (comment)

Pull Request resolved: #113195
Approved by: https://github.com/albanD
  • Loading branch information
min-jean-cho authored and pytorchmergebot committed Nov 15, 2023
1 parent f5ce4d8 commit 56c4532
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions torch/_tensor_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1909,11 +1909,19 @@ def add_docstr_all(method, docstr):
r"""
exponential_(lambd=1, *, generator=None) -> Tensor
Fills :attr:`self` tensor with elements drawn from the exponential distribution:
Fills :attr:`self` tensor with elements drawn from the PDF (probability density function):
.. math::
f(x) = \lambda e^{-\lambda x}
f(x) = \lambda e^{-\lambda x}, x > 0
.. note::
In probability theory, exponential distribution is supported on interval [0, :math:`\inf`) (i.e., :math:`x >= 0`)
implying that zero can be sampled from the exponential distribution.
However, :func:`torch.Tensor.exponential_` does not sample zero,
which means that its actual support is the interval (0, :math:`\inf`).
Note that :func:`torch.distributions.exponential.Exponential` is supported on the interval [0, :math:`\inf`) and can sample zero.
""",
)

Expand Down

0 comments on commit 56c4532

Please sign in to comment.