Continuous-time waiting models
Model waiting times or other nonnegative duration measurements under an exponential assumption.
SciPy · Function
scipy.stats.expon is SciPy's exponential continuous distribution object. Its standard density is exp(-x) for x ≥ 0, with loc and scale available for shifting and scaling.
Use the exponential distribution object through inherited continuous-distribution methods such as pdf, cdf, and rvs. The standard form has unit scale and support beginning at zero; loc shifts the origin, while scale stretches the distribution and corresponds to the reciprocal of the rate parameter.
scipy.stats.expon| Name | Type | Description |
|---|---|---|
loc | float, optional | Location parameter that shifts the distribution. |
scale | float, optional | Scale parameter controlling the distribution's scale; default is 1. |
method-specific arguments | varies | Arguments accepted by inherited methods depend on the operation, such as x, q, size, or random_state. |
The expon distribution object; its inherited methods return operation-specific results such as densities, probabilities, or random samples.
rv_continuous.scale; for rate λ, use scale=1/λ, and use loc separately for a shifted origin.from scipy.stats import expon
rate = 2.0
x = 0.5
pdf = expon.pdf(x, scale=1 / rate)
probability = expon.cdf(x, scale=1 / rate)
samples = expon.rvs(scale=1 / rate, size=3, random_state=7)
print(pdf)
print(probability)
print(samples)This evaluates the density and cumulative probability at x for a rate-2 exponential distribution, then draws three reproducible samples.
Model waiting times or other nonnegative duration measurements under an exponential assumption.
Evaluate likelihood components or probabilities for exponentially distributed observations.
Generate synthetic exponential observations for simulations and tests.
scipy.stats.expon?scipy.stats.expon represents an exponential continuous random variable and is an instance of rv_continuous. It provides distribution operations such as pdf, cdf, and random variate generation through the inherited interface.
Follow-up: How do you express a rate parameter λ? Use scale=1/λ, because SciPy's scale parameter is the reciprocal of the rate.
Its standardized density is \(f(x)=\exp(-x)\) for nonnegative x. The standard form therefore has location zero and scale one.
Follow-up: How would you shift the distribution? Supply a nonzero loc; combining it with scale transforms the standardized variable accordingly.
loc and scale affect the distribution?loc shifts the distribution and scale changes its spread. The documentation describes expon.pdf(x, loc, scale) using the standardized value \(y=(x-loc)/scale\), with the density divided by scale.
Follow-up: What common distribution is this a special case of? It is a gamma distribution with shape parameter a=1.
scipy.stats.gammascipy.stats.rv_continuousscipy.stats.expon.pdfscipy.stats.expon.cdfscipy.stats.expon.rvs