W3cubDocs

/PyTorch 2.9

torch.Tensor.geometric_

Tensor.geometric_(p, *, generator=None) → Tensor

Fills self tensor with elements drawn from the geometric distribution:

P(X=k)=(1p)k1p,k=1,2,...P(X=k) = (1 - p)^{k - 1} p, k = 1, 2, ...

Note

torch.Tensor.geometric_() k-th trial is the first success hence draws samples in {1,2,}\{1, 2, \ldots\}, whereas torch.distributions.geometric.Geometric() (k+1)(k+1)-th trial is the first success hence draws samples in {0,1,}\{0, 1, \ldots\}.

© 2025, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.9/generated/torch.Tensor.geometric_.html