class

Exponential

extendsExponentialFamily
Exponential(rate: Tensor | float, validate_args: bool | None = None)
source

Exponential distribution on [0,)[0, \infty).

Continuous distribution describing the waiting time between events of a Poisson process with rate λ\lambda. It is the continuous analogue of the lucid.distributions.Geometric distribution and the unique continuous distribution with the memoryless property.

Parameters

rateTensor or float
Rate parameter λ>0\lambda > 0. The mean of the distribution is 1/λ1/\lambda.
validate_argsbool= None
If True, validate parameter constraints at construction time.

Notes

Probability density on x0x \geq 0:

p(x;λ)=λeλxp(x; \lambda) = \lambda e^{-\lambda x}

Moments:

E[X]=1λ,Var[X]=1λ2,H[X]=1logλ\mathbb{E}[X] = \frac{1}{\lambda}, \qquad \mathrm{Var}[X] = \frac{1}{\lambda^2}, \qquad H[X] = 1 - \log \lambda

Memoryless property:

P(X>s+tX>s)=P(X>t)P(X > s + t \mid X > s) = P(X > t)

Special cases / relations:

  • Exponential(λ)=Gamma(1,λ)\mathrm{Exponential}(\lambda) = \mathrm{Gamma}(1, \lambda)
  • The sum of kk IID Exponential(λ)\mathrm{Exponential}(\lambda) variables is Gamma(k,λ)\mathrm{Gamma}(k, \lambda) (Erlang).
  • logU/λ-\log U / \lambda with UUniform(0,1)U \sim \mathrm{Uniform}(0, 1) is the inverse-CDF sampler used by rsample.

Examples

>>> import lucid
>>> from lucid.distributions import Exponential
>>> d = Exponential(rate=2.0)
>>> d.mean  # 1/rate
Tensor(0.5)
>>> d.rsample((4,))
Tensor([...])
>>> d.log_prob(lucid.tensor(1.0))
Tensor(-1.3069)

Methods (9)

dunder

__init__

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

Construct an Exponential distribution.

Parameters

rateTensor | float
Rate parameter λ>0\lambda > 0. The mean of the distribution is 1/λ1/\lambda.
validate_argsbool | None= None
If True, validate parameter constraints at construction time.

Notes

The Exponential distribution with rate λ\lambda has PDF:

p(x;λ)=λeλx,x0p(x; \lambda) = \lambda e^{-\lambda x}, \quad x \geq 0

It is the continuous analogue of the Geometric distribution and describes the waiting time between events in a Poisson process.

Examples

>>> from lucid.distributions import Exponential
>>> d = Exponential(rate=2.0)
>>> d.mean  # 1/rate = 0.5
Tensor(0.5)
prop

mean

Tensor
mean: Tensor
source

Expected value of the Exponential distribution.

E[X]=1λE[X] = \frac{1}{\lambda}

Returns

Tensor

Mean 1/λ1/\lambda, shape batch_shape.

Examples

>>> Exponential(rate=4.0).mean
Tensor(0.25)
prop

mode

Tensor
mode: Tensor
source

Mode of the Exponential distribution.

The Exponential distribution is monotonically decreasing on [0,)[0, \infty), so the mode is always zero regardless of the rate parameter.

mode=0\text{mode} = 0

Returns

Tensor

Zero tensor of shape batch_shape.

Examples

>>> Exponential(rate=5.0).mode
Tensor(0.0)
prop

variance

Tensor
variance: Tensor
source

Variance of the Exponential distribution.

Var[X]=1λ2\operatorname{Var}[X] = \frac{1}{\lambda^2}

Returns

Tensor

Variance 1/λ21/\lambda^2, shape batch_shape.

Examples

>>> Exponential(rate=2.0).variance
Tensor(0.25)
fn

rsample

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

Reparameterised sample via the inverse-CDF method.

Uses the transform X=log(1U)/λX = -\log(1 - U) / \lambda where UUniform(0,1)U \sim \text{Uniform}(0, 1). This is an exact reparameterisation — gradients flow through λ\lambda.

X=log(1U)λX = -\frac{\log(1 - U)}{\lambda}

Subtracting from 1 (rather than directly using UU) ensures the argument to log\log is bounded away from zero.

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 = Exponential(rate=1.0)
>>> x = d.rsample((500,))
>>> x.mean()  # approximately 1.0
fn

log_prob

Tensor
log_prob(value: Tensor)
source

Log-density of value under the Exponential distribution.

logp(x;λ)=logλλx\log p(x; \lambda) = \log \lambda - \lambda x

Parameters

valueTensor
Non-negative real values x0x \geq 0.

Returns

Tensor

Element-wise log-densities, shape batch_shape.

Examples

>>> d = Exponential(rate=1.0)
>>> d.log_prob(lucid.tensor(1.0))  # -1.0
Tensor(-1.0)
fn

cdf

Tensor
cdf(value: Tensor)
source

Cumulative distribution function of the Exponential distribution.

F(x;λ)=1eλx,x0F(x; \lambda) = 1 - e^{-\lambda x}, \quad x \geq 0

Parameters

valueTensor
Non-negative real values at which to evaluate the CDF.

Returns

Tensor

CDF values in [0,1][0, 1], shape batch_shape.

Examples

>>> Exponential(rate=1.0).cdf(lucid.tensor(1.0))  # 1 - e^-1 ≈ 0.632
Tensor(0.6321)
fn

icdf

Tensor
icdf(value: Tensor)
source

Inverse CDF (quantile function) of the Exponential distribution.

F1(u;λ)=log(1u)λF^{-1}(u; \lambda) = -\frac{\log(1 - u)}{\lambda}

Parameters

valueTensor
Probability values u[0,1)u \in [0, 1).

Returns

Tensor

Quantiles in [0,)[0, \infty), shape batch_shape.

Examples

>>> Exponential(rate=1.0).icdf(lucid.tensor(0.5))  # log(2) ≈ 0.693
Tensor(0.6931)
fn

entropy

Tensor
entropy()
source

Shannon entropy of the Exponential distribution (in nats).

H(X)=1logλH(X) = 1 - \log \lambda

The entropy decreases as the rate increases (concentrated distributions have lower uncertainty).

Returns

Tensor

Entropy in nats, shape batch_shape.

Examples

>>> Exponential(rate=1.0).entropy()  # 1 - log(1) = 1.0
Tensor(1.0)