torch.Tensor.geometric_ — PyTorch 2.7 documentation (original) (raw)

Shortcuts

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

Fills self tensor with elements drawn from the geometric distribution:

P(X=k)=(1−p)k−1p,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\}, whereastorch.distributions.geometric.Geometric() (k+1)(k+1)-th trial is the first success hence draws samples in {0,1,…}\{0, 1, \ldots\}.