torch.distributions.Exponential
class Exponential extends Distributionnew Exponential(rate: number | Tensor, options?: DistributionOptions)
- readonly
rate(Tensor) - – Rate parameter (lambda = 1/scale).
- readonly
arg_constraints(unknown) - readonly
support(unknown) - readonly
has_rsample(unknown) - readonly
mean(Tensor) - readonly
mode(Tensor) - readonly
variance(Tensor) - readonly
stddev(Tensor)
Exponential distribution: models the time until an event in a Poisson process.
Parameterized by rate λ (events per unit time). Fundamental for modeling waiting times, lifetimes, and durations in continuous time. Essential for:
- Modeling inter-event times in Poisson processes
- Reliability and lifetime modeling (e.g., equipment failure)
- Queue theory and arrival processes
- Bayesian exponential family models
- Mixture models with exponential components
- Prior distributions for rate parameters
The probability density function: f(x) = λ * e^(-λx) for x ≥ 0 Alternative parameterization: f(x) = (1/β) * e^(-x/β) with β = 1/λ (scale parameter)
- Rate vs Scale: rate = λ = 1/scale. Use rate 0 (positive)
- Memoryless: P(X s + t | X s) = P(X t) - unique memoryless distribution
- Variance equals mean²: Var(X) = (E[X])² (rare property)
- CDF closed form: F(x) = 1 - e^(-λx) enables efficient CDF/ICDF
- Minimum of exponentials: min(X₁, X₂, ..., Xₙ) ~ Exponential(λ₁ + λ₂ + ... + λₙ)
- Time to Poisson event: If N(t) ~ Poisson(λt), then inter-event times ~ Exp(λ)
- Rate must be positive: rate ≤ 0 causes errors
- Long tail: Distribution is right-skewed with slow decay
- Extreme values: Very large values possible but increasingly rare
- Model assumption: Real waiting times often have more structure (Weibull, Gamma)
Examples
// Standard exponential: λ = 1 (average waiting time = 1)
const exp_dist = new torch.distributions.Exponential(1);
const waiting_time = exp_dist.sample(); // how long until next event?
const wait_times = exp_dist.sample([1000]); // 1000 waiting times
// High rate: events happen frequently (short wait times)
const fast_events = new torch.distributions.Exponential(5); // λ = 5
const short_wait = fast_events.sample(); // typically small (fast events)
// Low rate: events are rare (long wait times)
const slow_events = new torch.distributions.Exponential(0.1); // λ = 0.1
const long_wait = slow_events.sample(); // typically large (rare events)
// Reliability modeling: equipment lifetime
const failure_rate = 0.005; // 5 failures per 1000 hours
const lifetime_dist = new torch.distributions.Exponential(failure_rate);
const equipment_life = lifetime_dist.sample(); // hours until failure
const mtbf = 1 / failure_rate; // mean time before failure
// Batched distributions with different rates
const rates = torch.tensor([1, 2, 5]); // different event frequencies
const dist = new torch.distributions.Exponential(rates);
const samples = dist.sample(); // [3] shaped samples
// First has long waits (λ=1), last has short waits (λ=5)
// Queue theory: inter-arrival times in M/M/1 queue
const arrival_rate = 2; // customers per minute
const interarrival = new torch.distributions.Exponential(arrival_rate);
const arrival_times = interarrival.sample([100]); // 100 inter-arrival times
// Memoryless property: P(X > 10 + 5 | X > 10) = P(X > 5)
const dist = new torch.distributions.Exponential(0.5);
const prob_gt_15 = 1 - dist.cdf(15);
const prob_gt_5 = 1 - dist.cdf(5);
// prob_gt_15 / prob_gt_10 ≈ prob_gt_5 (memoryless property)