class

Cauchy

extendsDistribution
Cauchy(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)
source

Cauchy distribution on R\mathbb{R} — 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 float
Location parameter x0Rx_0 \in \mathbb{R} (median and mode). The "mean" does not exist.
scaleTensor or float
Scale parameter γ>0\gamma > 0 (half-width at half-maximum).
validate_argsbool= None
If True, validate parameter constraints at construction time.

Notes

Probability density:

p(x;x0,γ)=1πγ[1+(xx0γ)2]1p(x; x_0, \gamma) = \frac{1}{\pi \gamma} \left[1 + \left(\frac{x - x_0}{\gamma}\right)^2\right]^{-1}

Cumulative distribution:

F(x;x0,γ)=1πarctan ⁣(xx0γ)+12F(x; x_0, \gamma) = \frac{1}{\pi} \arctan\!\left(\frac{x - x_0}{\gamma}\right) + \frac{1}{2}

Properties (no moments — all are undefined or infinite):

  • Median / mode: x0x_0
  • Mean / variance: undefined (integrals diverge)
  • Entropy: H[X]=log(4πγ)H[X] = \log(4 \pi \gamma)

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 α\alpha-stable distribution with stability index 1).

Reparameterised sampling uses the inverse-CDF X=x0+γtan(π(U12))X = x_0 + \gamma \tan(\pi(U - \tfrac{1}{2})).

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)

dunder

__init__

None
__init__(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)
source

Construct a Cauchy distribution.

Parameters

locTensor | float
Location parameter (median and mode) x0Rx_0 \in \mathbb{R}.
scaleTensor | float
Scale (half-width at half-maximum) parameter γ>0\gamma > 0.
validate_argsbool | None= None
If True, validate parameter constraints at construction time.

Notes

The Cauchy distribution has PDF:

p(x;x0,γ)=1πγ[1+(xx0γ)2]1p(x; x_0, \gamma) = \frac{1}{\pi \gamma} \left[1 + \left(\frac{x - x_0}{\gamma}\right)^2\right]^{-1}

The Cauchy is the Student's t-distribution with one degree of freedom. Because all moments of order 1\geq 1 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,))
fn

rsample

Tensor
rsample(sample_shape: tuple[int, ...] = ())
source

Reparameterised sample via the inverse-CDF method.

Uses the quantile function of the Cauchy distribution:

X=x0+γtan ⁣(π(U12))X = x_0 + \gamma \tan\!\bigl(\pi (U - \tfrac{1}{2})\bigr)

where UUniform(0,1)U \sim \text{Uniform}(0, 1). Gradients flow through both x0x_0 and γ\gamma.

Parameters

sample_shapetuple[int, ...]= ()
Leading shape dimensions for the sample batch. Default is ().

Returns

Tensor

Reparameterised samples of shape sample_shape + batch_shape.

Examples

>>> d = Cauchy(loc=0.0, scale=1.0)
>>> x = d.rsample((500,))
fn

log_prob

Tensor
log_prob(value: Tensor)
source

Log-density of value under the Cauchy distribution.

logp(x;x0,γ)=logπlogγlog ⁣(1+(xx0γ)2)\log p(x; x_0, \gamma) = -\log \pi - \log \gamma - \log\!\left(1 + \left(\frac{x - x_0}{\gamma}\right)^2\right)

Parameters

valueTensor
Real-valued observations.

Returns

Tensor

Element-wise log-densities, shape batch_shape.

Examples

>>> Cauchy(loc=0.0, scale=1.0).log_prob(lucid.tensor(0.0))
Tensor(-1.1447)
fn

cdf

Tensor
cdf(value: Tensor)
source

Cumulative distribution function of the Cauchy distribution.

F(x;x0,γ)=1πarctan ⁣(xx0γ)+12F(x; x_0, \gamma) = \frac{1}{\pi} \arctan\!\left(\frac{x - x_0}{\gamma}\right) + \frac{1}{2}

Parameters

valueTensor
Real values at which to evaluate the CDF.

Returns

Tensor

CDF values in (0,1)(0, 1), shape batch_shape.

fn

entropy

Tensor
entropy()
source

Shannon entropy of the Cauchy distribution (in nats).

H(X)=log(4πγ)H(X) = \log(4 \pi \gamma)

Returns

Tensor

Entropy in nats, shape batch_shape.

Examples

>>> Cauchy(loc=0.0, scale=1.0).entropy()  # log(4π) ≈ 2.531
Tensor(2.5310)