Cauchy
DistributionCauchy(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)Cauchy distribution on — heavy-tailed, all moments undefined.
The canonical example of a pathological heavy-tailed distribution: its tails decay so slowly that no integer moment (mean, variance, skew, kurtosis) is defined. The Cauchy is the Student's-t distribution with one degree of freedom and arises naturally as the ratio of two independent standard Normals.
Parameters
locTensor or floatscaleTensor or floatvalidate_argsbool= NoneTrue, validate parameter constraints at construction time.Notes
Probability density:
Cumulative distribution:
Properties (no moments — all are undefined or infinite):
- Median / mode:
- Mean / variance: undefined (integrals diverge)
- Entropy:
Sample mean does not converge — the strong law of large numbers fails for IID Cauchy variates. Any finite-sample average of Cauchy draws is itself Cauchy-distributed with the same parameters.
Stability: a sum of independent Cauchy variables remains Cauchy (it is an -stable distribution with stability index 1).
Reparameterised sampling uses the inverse-CDF .
Examples
>>> import lucid
>>> from lucid.distributions import Cauchy
>>> d = Cauchy(loc=0.0, scale=1.0)
>>> d.rsample((4,))
Tensor([...])
>>> d.log_prob(lucid.tensor(0.0))
Tensor(-1.1447)Methods (5)
__init__
→None__init__(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)Construct a Cauchy distribution.
Parameters
locTensor | floatscaleTensor | floatvalidate_argsbool | None= NoneTrue, validate parameter constraints at construction time.Notes
The Cauchy distribution has PDF:
The Cauchy is the Student's t-distribution with one degree of freedom. Because all moments of order are undefined, it is a canonical example of a heavy-tailed distribution where the sample mean does not converge to any value.
Examples
>>> from lucid.distributions import Cauchy
>>> d = Cauchy(loc=0.0, scale=1.0)
>>> x = d.rsample((1000,))rsample
→Tensorrsample(sample_shape: tuple[int, ...] = ())Reparameterised sample via the inverse-CDF method.
Uses the quantile function of the Cauchy distribution:
where . Gradients flow through both and .
Parameters
sample_shapetuple[int, ...]= ()().Returns
TensorReparameterised samples of shape sample_shape + batch_shape.
Examples
>>> d = Cauchy(loc=0.0, scale=1.0)
>>> x = d.rsample((500,))log_prob
→Tensorlog_prob(value: Tensor)Log-density of value under the Cauchy distribution.
Parameters
valueTensorReturns
TensorElement-wise log-densities, shape batch_shape.
Examples
>>> Cauchy(loc=0.0, scale=1.0).log_prob(lucid.tensor(0.0))
Tensor(-1.1447)cdf
→Tensorcdf(value: Tensor)Cumulative distribution function of the Cauchy distribution.
Parameters
valueTensorReturns
TensorCDF values in , shape batch_shape.
entropy
→Tensorentropy()Shannon entropy of the Cauchy distribution (in nats).
Returns
TensorEntropy in nats, shape batch_shape.
Examples
>>> Cauchy(loc=0.0, scale=1.0).entropy() # log(4π) ≈ 2.531
Tensor(2.5310)