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