Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

SciPy · Function

stats.expon

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.

How it works

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.

Syntax

scipy.stats.expon

Parameters

NameTypeDescription
locfloat, optionalLocation parameter that shifts the distribution.
scalefloat, optionalScale parameter controlling the distribution's scale; default is 1.
method-specific argumentsvariesArguments accepted by inherited methods depend on the operation, such as x, q, size, or random_state.

Returns

The expon distribution object; its inherited methods return operation-specific results such as densities, probabilities, or random samples.

Key points

  • The object models the exponential continuous probability distribution.
  • It inherits the generic continuous-distribution methods supplied by rv_continuous.
  • In standardized form, its density decays exponentially as exp(-x).
  • Use loc for translation and scale for changing the distribution's size.
  • When working with a rate λ, convert it to SciPy's scale parameter as its reciprocal.
  • The exponential family is contained within the gamma family at shape one.

Common mistakes

  • Do not pass a rate directly as scale; for rate λ, use scale=1/λ, and use loc separately for a shifted origin.
  • The standard exponential density is supported only for nonnegative x; values below the support do not follow the stated density.

Example: Evaluate and sample an exponential distribution

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.

When to use it

Continuous-time waiting models

Model waiting times or other nonnegative duration measurements under an exponential assumption.

Density and probability calculations

Evaluate likelihood components or probabilities for exponentially distributed observations.

Random sampling

Generate synthetic exponential observations for simulations and tests.

Interview questions

QWhat is 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.

QWhat density does the standard distribution use?

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.

QHow do 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.gamma
  • scipy.stats.rv_continuous
  • scipy.stats.expon.pdf
  • scipy.stats.expon.cdf
  • scipy.stats.expon.rvs

Source: scipy.stats.expon — SciPy v1.18.0 Manual. Checked 2026-10-15.