Course contents 06 / 22

06 / 22 · Random Variables

Continuous distributions

Interval probabilities, densities and quantiles, with checked examples for uniform, exponential, normal, gamma and beta models.

On this page 8

A rounded measurement can have a probability table even when its underlying value varies continuously. Suppose we construct a mathematical model on the interval from −1 to 3, with more probability near the upper end. Asking for the probability of the exact value 2 will give zero. Asking for the probability of a reading between 0 and 2 will give one half. The interval, including its width, carries the probability.

Densities#

In Discrete distributions, we added probabilities attached to individual values. For an absolutely continuous distribution, we instead define a nonnegative probability density ff whose total integral is one. For any interval with a<ba<b,

∫−∞∞f(x) dx=1,P(a<X≤b)=∫abf(x) dx.\begin{aligned} \int_{-\infty}^{\infty}f(x)\,dx&=1,\\ P(a<X\le b)&=\int_a^b f(x)\,dx. \end{aligned}

The integral over a single point is zero, so changing either interval endpoint from open to closed leaves the probability unchanged. A continuous cumulative distribution need not have a density: singular continuous distributions are possible. Here we work with the absolutely continuous case, where these integral formulas apply (Siegrist, Continuous Distributions).

Our independently stipulated example has a linearly increasing density:

f(x)={(x+1)/8,−1≤x≤3,0,x∉[−1,3].f(x)=\begin{cases} (x+1)/8,&-1\le x\le3,\\ 0,&x\notin[-1,3]. \end{cases}

Its normalization follows by integrating the line. The same antiderivative gives the interval probability:

∫−13x+18 dx=[(x+1)216]−13=1,P(0≤X≤2)=916−116=12.\begin{aligned} \int_{-1}^{3}\frac{x+1}{8}\,dx &=\left[\frac{(x+1)^2}{16}\right]_{-1}^{3}=1,\\ P(0\le X\le2) &=\frac{9}{16}-\frac{1}{16}=\frac12. \end{aligned}

A density has units reciprocal to those of the measurement. If we express the same value as Y=X/5Y=X/5, an interval of width dydy corresponds to width 5 dy5\,dy on the original scale. Preserving its probability therefore gives, for −1/5<y<3/5-1/5<y<3/5,

fY(y)=5fX(5y)=5(5y+1)8.f_Y(y)=5f_X(5y)=\frac{5(5y+1)}8.

The density approaches 5/25/2 at the upper edge. Values above one are valid; the integral over the whole support is still one. At a continuity point of ff, the probability in a short interval is approximately f(x) hf(x)\,h for width h>0h>0. The approximation can fail near a boundary or across a rapidly changing density.

Figure

Area and accumulated probability

Density f(x)

Density f(x)Density rises linearly from 0 to 1/2. A trapezoid between 0 and 2 has area 1/2.-1023x01/2area 1/2

Cumulative probability F(x)

Cumulative probability F(x)The CDF increases quadratically from 0 to 1. It equals 1/16 at x=0 and 9/16 at x=2.-1023x011/169/16
Density (x+1)/8 on [−1,3]. The shaded area between 0 and 2 is 1/2; the corresponding CDF increase is from 1/16 to 9/16. Both panels describe the same stipulated model.

The distribution function and quantiles#

The cumulative distribution function, or CDF, records the probability accumulated up to a threshold. It is defined for every real-valued random variable. For a density model,

F(x)=P(X≤x)=∫−∞xf(t) dt.F(x)=P(X\le x)=\int_{-\infty}^{x}f(t)\,dt.

A CDF is nondecreasing and right-continuous, with limits zero and one at the two ends of the real line. Subtracting its values gives P(a<X≤b)=F(b)−F(a)P(a<X\le b)=F(b)-F(a). The fundamental theorem of calculus gives F′(x)=f(x)F'(x)=f(x) wherever the density is continuous; more generally the equality holds almost everywhere for an absolutely continuous CDF.

For our rising density, integration gives

F(x)={0,x<−1,(x+1)2/16,−1≤x≤3,1,x>3.F(x)=\begin{cases} 0,&x<-1,\\ (x+1)^2/16,&-1\le x\le3,\\ 1,&x>3. \end{cases}

We can also start with a required probability and seek its threshold. For 0<p<10<p<1, define the lower quantile by

Q(p)=inf⁡{x:F(x)≥p}.Q(p)=\inf\{x:F(x)\ge p\}.

The infimum selects the first threshold reaching the requested probability. When the CDF is continuous and strictly increasing across its support, solving F(x)=pF(x)=p gives the ordinary inverse. In this example,

Q(p)=4p−1,Q(9/16)=2,Q(1/2)=22−1≈1.828427.\begin{aligned} Q(p)&=4\sqrt p-1,\\ Q(9/16)&=2,\\ Q(1/2)&=2\sqrt2-1\approx1.828427. \end{aligned}

The generalized definition also handles flat sections. Consider a separate model which chooses uniformly from [−1,0][-1,0] with probability 1/21/2 and uniformly from [2,4][2,4] otherwise. Its CDF is 1/21/2 throughout [0,2][0,2]. Every point in that interval is a median, while the lower-quantile convention selects Q(1/2)=0Q(1/2)=0. An inverse routine needs this convention when a solution is not unique (Siegrist, Distribution and Quantile Functions).

Uniform#

If equal-length subintervals inside a bounded range should have equal probabilities, a constant density implements that assumption. For finite endpoints a<ba<b, write U∼Uniform⁡(a,b)U\sim\operatorname{Uniform}(a,b). Requiring total mass one determines the height. Integrating and then solving for the threshold gives

fU(x)=1b−a,a<x<b,FU(x)=x−ab−a,a≤x≤b,QU(p)=a+(b−a)p,0<p<1.\begin{aligned} f_U(x)&=\frac1{b-a},\quad a<x<b,\\ F_U(x)&=\frac{x-a}{b-a},\quad a\le x\le b,\\ Q_U(p)&=a+(b-a)p,\quad 0<p<1. \end{aligned}

The density is zero outside the interval; the CDF is zero below it and one above it. For our choice a=−2a=-2 and b=5b=5, the interval from 1 to 3 occupies two of the seven available length units, so its probability is 2/72/7. The upper quartile is QU(3/4)=13/4Q_U(3/4)=13/4.

Uniformity belongs to a chosen scale. If UU is uniform on [0,1][0,1] and V=U2V=U^2, then P(V≤v)=P(U≤v)=vP(V\le v)=P(U\le\sqrt v)=\sqrt v for 0≤v≤10\le v\le1. The transformed distribution has a curved CDF. Calling a model uniform therefore requires specifying the variable as well as its allowed range.

Exponential#

The geometric distribution counts independent trials until the first success. To obtain a waiting time, place trials at intervals of length Δ>0\Delta>0. Set their success probability to pΔ=λΔp_\Delta=\lambda\Delta, where the rate λ>0\lambda>0 is fixed and Δ<1/λ\Delta<1/\lambda. If KK counts trials starting at one, define TΔ=ΔKT_\Delta=\Delta K.

For fixed t≥0t\ge0, waiting longer than tt requires failure in all trials scheduled by that time. There are ⌊t/Δ⌋\lfloor t/\Delta\rfloor such trials, hence

P(TΔ>t)=(1−λΔ)⌊t/Δ⌋.P(T_\Delta>t)=(1-\lambda\Delta)^{\lfloor t/\Delta\rfloor}.

Taking logarithms makes the limit explicit. We use log⁡(1−u)=−u+O(u2)\log(1-u)=-u+O(u^2) as u→0u\to0 and Δ⌊t/Δ⌋→t\Delta\lfloor t/\Delta\rfloor\to t. The logarithm tends to −λt-\lambda t, giving the exponential distribution:

S(t)=P(T>t)=e−λt,F(t)=1−e−λt,f(t)=λe−λt,t>0,Q(p)=−log⁡(1−p)λ,0<p<1.\begin{aligned} S(t)&=P(T>t)=e^{-\lambda t},\\ F(t)&=1-e^{-\lambda t},\\ f(t)&=\lambda e^{-\lambda t},\quad t>0,\\ Q(p)&=-\frac{\log(1-p)}{\lambda},\quad 0<p<1. \end{aligned}

Here SS is the survival function. The density comes from differentiating FF; the quantile comes from solving F(t)=pF(t)=p. For t<0t<0, both the density and CDF are zero. With our chosen rate λ=3/5\lambda=3/5, the discretization at t=2t=2 approaches the limit as follows:

Trial spacing Δ\DeltaP(TΔ>2)P(T_\Delta>2)
0.500.240100
0.200.278501
0.050.295712

The limiting probability is e−6/5≈0.301194e^{-6/5}\approx0.301194. These are computed probabilities of stipulated models, not observations of a real arrival process.

Figure

Reducing the trial spacing

Discrete waiting approaches continuous waitingThree decreasing curves start at one. The step curves approximate the smooth exponential. Trials are more frequent with spacing 0.2 than with spacing 0.5. A vertical line marks time 2.0123400.51S(t)t

Δ = 0.5

Δ = 0.2

Continuous limit

Success probability in one trial: λΔ.

Rate λ=3/5. Steps show P(TΔ>t) for Δ=0.5 and 0.2; the blue curve is exp(−3t/5). At trial times the lower step value applies. At t=2 the values are 0.240100, 0.278501 and 0.301194.

The exponential law is memoryless. For s,t≥0s,t\ge0, conditioning on survival to ss gives

P(T>s+t∣T>s)=e−λ(s+t)e−λs=e−λt.P(T>s+t\mid T>s) =\frac{e^{-\lambda(s+t)}}{e^{-\lambda s}} =e^{-\lambda t}.

Elapsed waiting time leaves the conditional distribution of the remaining wait unchanged. This is a substantive modeling assumption. For a uniform wait on [0,4][0,4], the probability of surviving past 3 given survival past 1 is 1/31/3, whereas surviving past 2 unconditionally has probability 1/21/2.

Conversely, for a proper nonnegative waiting time with positive survival at every finite time, memorylessness implies S(s+t)=S(s)S(t)S(s+t)=S(s)S(t). Iterating this identity determines SS on rational times; right-continuity determines it on all times. The result is S(t)=e−λtS(t)=e^{-\lambda t} with λ>0\lambda>0 (Siegrist, The Exponential Distribution, Memoryless Property). No empirical waiting-time dataset is guaranteed to satisfy this assumption.

Normal#

A symmetric model with an unbounded range is often useful for fluctuations around a center. Define the normal distribution X∼N(μ,σ2)X\sim\mathcal N(\mu,\sigma^2) for μ∈R\mu\in\mathbb R and σ>0\sigma>0 by

fX(x)=1σ2πexp⁡(−(x−μ)22σ2).f_X(x)=\frac1{\sigma\sqrt{2\pi}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right).

The second parameter is the variance; σ\sigma is the standard deviation. The normalizing constant follows from the Gaussian integral. One proof squares the integral of e−x2/2e^{-x^2/2} and uses polar coordinates to evaluate the resulting two-dimensional integral as 2π2\pi (Siegrist, The Normal Distribution, Standard Normal Distribution).

Subtracting the center and measuring distance in units of σ\sigma gives Z=(X−μ)/σ∼N(0,1)Z=(X-\mu)/\sigma\sim\mathcal N(0,1). Define its CDF as Φ\Phi. Transforming the two endpoints then gives

P(a<X≤b)=Φ(b−μσ)−Φ(a−μσ).P(a<X\le b) =\Phi\left(\frac{b-\mu}{\sigma}\right) -\Phi\left(\frac{a-\mu}{\sigma}\right).

For the independently chosen parameters μ=7/4\mu=7/4 and σ=3/5\sigma=3/5, the intervals within one, two and three standard deviations have the following probabilities. Their values depend only on the standardized endpoints, so the same table applies to every normal distribution.

Distance from μ\muProbability inside
At most σ\sigma0.682689
At most 2σ2\sigma0.954500
At most 3σ3\sigma0.997300

Symmetry gives P(∣Z∣>2.5)=2[1−Φ(2.5)]≈0.012419P(|Z|>2.5)=2[1-\Phi(2.5)]\approx0.012419. The familiar percentages are properties of a normal model. Knowing a variable’s mean and variance alone does not establish these tail probabilities. A normal model also assigns positive probability to every open interval, which matters when the quantity has strict physical bounds.

Gamma#

An exponential variable describes one memoryless waiting stage. A sum of several independent stages with the same rate motivates the gamma family. We use a shape α>0\alpha>0 and a rate β>0\beta>0. Define the gamma function and the density by

Γ(α)=∫0∞uα−1e−u du,fX(x)=βαΓ(α)xα−1e−βx,x>0.\begin{aligned} \Gamma(\alpha)&=\int_0^\infty u^{\alpha-1}e^{-u}\,du,\\ f_X(x)&=\frac{\beta^\alpha}{\Gamma(\alpha)} x^{\alpha-1}e^{-\beta x},\quad x>0. \end{aligned}

The density is zero for negative xx; its value at zero can be chosen arbitrarily without changing probabilities. Near zero, the defining integral is finite because α>0\alpha>0; at infinity, exponential decay dominates the power. Substituting u=βxu=\beta x in the density integral gives exactly Γ(α)/Γ(α)=1\Gamma(\alpha)/\Gamma(\alpha)=1. Integration by parts gives Γ(α+1)=αΓ(α)\Gamma(\alpha+1)=\alpha\Gamma(\alpha), and Γ(1)=1\Gamma(1)=1 gives Γ(n)=(n−1)!\Gamma(n)=(n-1)! for positive integers.

For integer shape nn, the density is that of a sum of nn independent exponential variables of rate β\beta. This follows by induction using convolution; see the proof in Siegrist, The Gamma Distribution, Poisson Process. At shape one, the formula itself reduces to the exponential density. Positive noninteger shapes remain valid density models, without an interpretation as a literal noninteger count of stages.

For our choice α=3\alpha=3 and β=2\beta=2, we obtain

fX(x)=4x2e−2x,x>0,FX(x)=1−e−2x(1+2x+2x2),x≥0,P(X≤1)=1−5e−2≈0.323324.\begin{aligned} f_X(x)&=4x^2e^{-2x},\quad x>0,\\ F_X(x)&=1-e^{-2x}(1+2x+2x^2),\quad x\ge0,\\ P(X\le1)&=1-5e^{-2}\approx0.323324. \end{aligned}

The CDF is checked directly: its value at zero is zero, its limit is one, and differentiating it gives 4x2e−2x4x^2e^{-2x}. Parameters need units too. The rate β\beta has inverse units of XX; a scale parameter would be θ=1/β\theta=1/\beta. In this example the scale is 1/21/2, so supplying a scale of 2 to an implementation would specify a different distribution.

Beta#

For a continuously varying proportion, the interval [0,1][0,1] is a natural support. The beta family controls how density accumulates near its two ends. For α,β>0\alpha,\beta>0, define

B(α,β)=∫01uα−1(1−u)β−1 du,fX(x)=xα−1(1−x)β−1B(α,β),0<x<1.\begin{aligned} B(\alpha,\beta)&=\int_0^1u^{\alpha-1}(1-u)^{\beta-1}\,du,\\ f_X(x)&=\frac{x^{\alpha-1}(1-x)^{\beta-1}}{B(\alpha,\beta)}, \quad 0<x<1. \end{aligned}

The density is zero outside the interval. Both endpoint integrals are finite because their power exponents exceed −1. Dividing by BB normalizes the density. The two beta parameters are shapes; the symbol β\beta no longer denotes the gamma rate. We choose the distribution family before interpreting its parameters.

Our example uses α=2\alpha=2 and β=3\beta=3. Expanding and integrating x(1−x)2x(1-x)^2 over [0,1][0,1] gives B(2,3)=1/12B(2,3)=1/12. Consequently,

fX(x)=12x(1−x)2,FX(x)=6x2−8x3+3x4,0≤x≤1,P(1/4≤X≤3/4)=FX(3/4)−FX(1/4)=11/16.\begin{aligned} f_X(x)&=12x(1-x)^2,\\ F_X(x)&=6x^2-8x^3+3x^4,\quad 0\le x\le1,\\ P(1/4\le X\le3/4)&=F_X(3/4)-F_X(1/4)=11/16. \end{aligned}

Differentiating the density gives fX′(x)=12(1−x)(1−3x)f'_X(x)=12(1-x)(1-3x). It rises up to x=1/3x=1/3 and falls afterwards, so its mode is 1/31/3. When both shape parameters equal one, the density is uniform. A shape below one permits the density to diverge at its corresponding endpoint while remaining integrable. Even then, an exact endpoint has zero probability under the beta model (Siegrist, The Beta Distribution).

What changed#

Sums of point masses have become integrals over intervals. The CDF still answers the same threshold question for discrete and continuous variables. A density plot needs its horizontal scale: its height alone does not specify a probability.

Limitations#

Recording precision changes the observed distribution. Round our rising-density variable to the nearest integer and call the result RR. Integrating over the rounding bins gives:

Recorded RR−10123
Probability1/641/81/43/815/64

For instance, R=2R=2 corresponds to 1.5≤X<2.51.5\le X<2.5 and has probability 3/83/8. Ties have probability zero. A continuous model for the latent value is compatible with repeated identical recorded readings, and their probabilities require integrating across bins.

A continuous density also cannot represent a genuine atom, such as a positive probability of exactly zero. Such a model needs an explicit discrete component. Finally, a fitted family and its estimated quantiles carry uncertainty: calculating its p99 exactly does not establish the population p99 or a guaranteed upper bound on future observations.

What you should remember#

  • Interval probabilities are areas under a density; point probabilities are zero.
  • A CDF accumulates mass; a lower quantile picks the first threshold reaching it.
  • Uniformity depends on the measurement scale, and exponential waiting assumes memorylessness.
  • Normal tail percentages require a normal model.
  • Gamma rate and scale are reciprocals; beta shapes describe a bounded density.

Code#

This standard-library calculation reproduces selected values above. It evaluates formulas directly; no fitted model, external dataset or random sample is involved.

from math import exp, erf, sqrt

print(f"rising median: {2 * sqrt(2) - 1:.6f}")
for delta, n in [(0.5, 4), (0.2, 10), (0.05, 40)]:
    print(f"survival at 2, delta={delta:.2f}: {(1 - 0.6 * delta) ** n:.6f}")
print(f"continuous survival at 2: {exp(-1.2):.6f}")
print(f"normal within 2 sigma: {erf(2 / sqrt(2)):.6f}")
print(f"gamma CDF at 1: {1 - 5 * exp(-2):.6f}")
rising median: 1.828427
survival at 2, delta=0.50: 0.240100
survival at 2, delta=0.20: 0.278501
survival at 2, delta=0.05: 0.295712
continuous survival at 2: 0.301194
normal within 2 sigma: 0.954500
gamma CDF at 1: 0.323324

Next#

Changing units preserved interval probabilities while changing density heights. Squaring a variable already changed a uniform CDF into a curved one. Functions of random variables develops the general method, including transformations that send several input values to the same output.

References#

Kyle Siegrist, Random: Probability, Mathematical Statistics, and Stochastic Processes, online edition checked 16 November 2026. The following sections support the definitions and named distribution facts; the worked inputs, calculations, code and figures here are independently composed.