ExponentialDistribution

Represents the exponential distribution, a continuous probability distribution that models the time between events in a Poisson process.

The exponential distribution is commonly used to model waiting times, such as the time until the next customer arrives, the time until a component fails, or the time between radioactive decays. It is the continuous analog of the geometric distribution and is the only continuous distribution with the memoryless property: the probability of waiting an additional amount of time is independent of how long you have already waited.

The distribution is parameterized by rate (often written as lambda), which is the average number of events per unit time. A higher rate means events happen more frequently and the distribution is concentrated closer to zero. The support is [0, +infinity) -- only non-negative values have positive density.

Random sampling uses the inverse CDF method, which transforms a single uniform random draw into an exponentially distributed value.

Example:

// Model a server that handles 2 requests per second on average
val dist = ExponentialDistribution(rate = 2.0)
dist.mean // 0.5 (average wait is 1/rate = 0.5 seconds)
dist.variance // 0.25
dist.pdf(0.0) // 2.0 (density is highest at zero)
dist.cdf(1.0) // 0.8647 (about 86% chance the next request arrives within 1 second)
dist.quantile(0.5) // 0.3466 (the median wait time)
dist.sample(Random(42)) // a single random wait time

// Standard exponential (rate=1)
val standard = ExponentialDistribution.STANDARD
standard.mean // 1.0

Constructors

Link copied to clipboard
constructor(rate: Double = 1.0)

Types

Link copied to clipboard
object Companion

Provides the pre-built standard exponential distribution constant.

Properties

Link copied to clipboard
open override val entropy: Double

The differential entropy of this distribution in nats, computed from rate.

Link copied to clipboard
open override val kurtosis: Double

The excess kurtosis of this distribution, always 6 for any exponential distribution.

Link copied to clipboard
open override val mean: Double

The mean of this distribution, equal to the reciprocal of rate.

Link copied to clipboard

the rate parameter (lambda), representing the average number of events per unit time. Must be positive. Default is 1.0, which gives the standard exponential distribution.

Link copied to clipboard
open override val skewness: Double

The skewness of this distribution, always 2 for any exponential distribution.

Link copied to clipboard
open override val variance: Double

The variance of this distribution, equal to the reciprocal of rate squared.

Functions

Link copied to clipboard
open override fun cdf(x: Double): Double

Computes the cumulative distribution function at x.

Link copied to clipboard
open override fun logPdf(x: Double): Double

Computes the natural logarithm of the probability density at x.

Link copied to clipboard
open override fun pdf(x: Double): Double

Computes the probability density at x.

Link copied to clipboard
open override fun quantile(p: Double): Double

Computes the quantile (inverse CDF) for the given probability p.

Link copied to clipboard
open override fun sample(random: Random): Double

Draws a single random value from this exponential distribution using the inverse CDF method.

Link copied to clipboard
open override fun sf(x: Double): Double

Computes the survival function at x.