PDF and CDF
Compare density and cumulative curves for uniform, exponential, normal and beta distributions
PDF f(x)(shaded area = probability)
CDF F(x) = P(X ≤ x)(highlighted height = same probability)
Drag on either chart to move the nearest marker. Both charts share the same x-axis.
- P(-1.00 ≤ X ≤ 2.00)
- 0.6563
- F(a), F at a = -1.00
- 0.2525
- F(b), F at b = 2.00
- 0.9088
- Density f(a), not a probability
- 0.2130
area = F(b) − F(a) = 0.9088 − 0.2525
- Mean
- 0.000
- Median
- 0.000
- Variance
- 2.250
- Std. dev.
- 1.500
f(x) = e^(−(x − μ)² / (2σ²)) / (σ√(2π))
F(x) = Φ((x − μ) / σ) = ½[1 + erf((x − μ) / (σ√2))]
- x with F(x) = 0.9
- 1.9223
90.0% of the probability lies below this value: it is the 90.0th percentile.
Density and cumulative probability
A continuous random variable, like a waiting time or a measurement, can take any value in an interval. There are infinitely many such values, so the chance of hitting any one of them exactly is zero. Instead of listing probabilities, we describe X with a probability density function f(x): the probability that X lands in an interval is the area under f over that interval.
The cumulative distribution function F(x) = P(X ≤ x) records that area as a running total from the left. It answers every interval question with a subtraction: P(a ≤ X ≤ b) = F(b) − F(a). The visualizer shows this side by side: the shaded area on the PDF and the highlighted rise on the CDF are always the same number.
Going the other way, from a probability to a value, is the job of the quantile function F⁻¹(p). It gives medians, percentiles and the critical values used in confidence intervals and hypothesis tests. For the uniform and exponential it has a simple formula; for the normal, beta and gamma it is computed numerically, here by bisection on an accurate CDF.
Density, not probability
CDF is the running total
Two views of one thing
Quantiles invert the CDF
Key formulas
From density to probability
P(a ≤ X ≤ b) = ∫ab f(x) dx = F(b) − F(a)
- f(x)
- probability density function, f(x) ≥ 0 and total area 1
CDF and PDF are linked by calculus
F(x) = ∫−∞x f(t) dt, f(x) = F′(x)
Mean, variance and quantiles
E[X] = ∫ x f(x) dx, Var(X) = ∫ (x − E[X])² f(x) dx, xp = F⁻¹(p)
- x_p
- the p-quantile; x_0.5 is the median
The distributions in the visualizer
| Distribution | Support | Mean | Variance | Median |
|---|---|---|---|---|
| Uniform(a, b) | [a, b] | (a + b) / 2 | (b − a)² / 12 | (a + b) / 2 |
| Exponential(λ) | [0, ∞) | 1 / λ | 1 / λ² | ln 2 / λ |
| Normal(μ, σ) | (−∞, ∞) | μ | σ² | μ |
| Beta(α, β) | [0, 1] | α / (α + β) | αβ / ((α + β)²(α + β + 1)) | no closed form |
| Gamma(k, θ) | [0, ∞) | kθ | kθ² | no closed form |
How to use this visualizer
- 1Pick a distribution and move its parameter sliders. Both charts and the summary (mean, median, variance) update together.
- 2Choose which probability to show: P(X ≤ a), P(a ≤ X ≤ b) or P(X ≥ a).
- 3Drag on either chart to move the nearest marker. The shaded area on the PDF and the highlighted bar on the CDF axis always show the same probability.
- 4Compare the density f(a) with the probabilities. Squeeze a normal to σ = 0.3 or a beta to α = β = 10 and the density rises well above 1, while every probability stays between 0 and 1.
- 5Type a probability p into the quantile box to find the x with F(x) = p (the purple point on the CDF), then press Move a to this quantile to check that the area to its left is p.
Common misconception
The height of a PDF is not a probability. A Uniform(0, 0.5) density equals 2 everywhere on its support, and a Beta(0.5, 0.5) density is infinite at both ends, yet both have total area exactly 1. To get a probability you always need a width: an area under the PDF, or a difference of two CDF values.Practice problems
Problem 1: Waiting for a bus
Show solutionHide solution
Mean 1/λ = 2, so λ = 0.5 and F(x) = 1 − e^(−0.5x)
P(1 ≤ X ≤ 3) = F(3) − F(1) = e^(−0.5) − e^(−1.5) = 0.60653 − 0.22313 = 0.38340
Median: 1 − e^(−0.5m) = 0.5, so m = ln 2 / 0.5 ≈ 1.386 minutes
90th percentile: 1 − e^(−0.5x) = 0.9, so x = −ln(0.1) / 0.5 = 2 ln 10 ≈ 4.605 minutes
P ≈ 0.383, median ≈ 1.39 min, 90th percentile ≈ 4.61 min
Problem 2: A beta density
Show solutionHide solution
F(x) = ∫₀ˣ 6t(1 − t) dt = 3x² − 2x³ for 0 ≤ x ≤ 1
P(X ≤ 0.25) = 3(0.0625) − 2(0.015625) = 0.1875 − 0.03125 = 0.15625
By symmetry F(0.75) = 1 − 0.15625 = 0.84375
P(0.25 ≤ X ≤ 0.75) = 0.84375 − 0.15625 = 0.6875
Mean = α/(α + β) = 2/4 = 0.5
Variance = αβ/((α + β)²(α + β + 1)) = 4/(16 × 5) = 0.05
Largest density: f(0.5) = 6 × 0.5 × 0.5 = 1.5, which is more than 1
F(x) = 3x² − 2x³; 0.15625; 0.6875; mean 0.5; variance 0.05; max f = 1.5
Related topics
Binomial Distribution
A discrete distribution, where probabilities are bar heights rather than areas
Confidence Intervals
Normal and t quantiles set the width of every interval
Normal Distribution
A closer look at the bell curve, z-scores and the 68-95-99.7 rule
Integration Basics
Areas under curves, the calculus behind every CDF
Discussion
Questions, ideas or a different approach? Join the conversation.