← SciSim / Statistics
Uniform Distribution
Tier: Standard Undergraduate
§1 Interactive Simulation
a (lower)
0
b (upper)
1
Mean=(a+b)/2
0.5
Var=(b-a)²/12
0.0833
P(x₁≤X≤x₂)
n samples
0
a (lower bound) 0
b (upper bound) 1
Query x₁ 0.25
Query x₂ 0.75
n for CLT sum 12
Speed 30/s
§2 The Idea, Step by Step

Start — the everyday picture. Imagine a bus you know will arrive sometime in the next 30 minutes, but every moment is just as likely as any other: it is no more likely to show up at minute 3 than at minute 27. There is no "favorite" time. That single idea — every spot in a range is equally likely — is the whole heart of the uniform distribution. The chance is spread perfectly flat across a stretch, like butter spread evenly on a slice of bread.

Build — name the pieces. Call the earliest value $a$ and the latest value $b$. Because the chance is spread evenly and all the probability has to add up to 1, the height of the flat curve must be $\frac{1}{b-a}$ — a wider interval forces a shorter curve. The chance of landing in a smaller piece is simply that piece's width divided by the total width: $P(x_1\le X\le x_2)=\frac{x_2-x_1}{b-a}$. For the bus on $[0,30]$, the chance it comes in the first 10 minutes is $\frac{10}{30}=\frac13$, and the average wait sits right in the middle, $\frac{a+b}{2}=15$ minutes — exactly what intuition says.

Deepen — the precise form. Formally the density is $f(x)=\frac{1}{b-a}$ for $a\le x\le b$ (and $0$ outside), with mean $\frac{a+b}{2}$ and variance $\frac{(b-a)^2}{12}$ — note the width is squared, a step students often drop. Its real superpower: for any continuous distribution, feeding its variable through its own CDF produces a uniform value (the probability integral transform), so one stream of $U(0,1)$ numbers run through an inverse CDF can manufacture samples from any distribution. That is why the uniform is the engine room of Monte Carlo simulation.

Try this in the sim above. (1) Drag $b$ far away from $a$ and watch the flat curve drop — wider spread means lower height and bigger variance. (2) Set $x_1$ and $x_2$ to cover half the interval and confirm the $P(x_1\le X\le x_2)$ readout lands near $0.5$. (3) Open the "Sum → Normal (CLT)" tab, set $n=12$, and press Play — watch a pile of flat uniforms morph into a bell curve, the classic 12-uniform trick.

§3 Mathematical Derivation

Continuous Uniform Distribution — U(a,b)

$$\boxed{f(x;a,b)=\frac{1}{b-a},\quad a\le x\le b}$$

$E[X]=\frac{a+b}{2},\quad\text{Var}(X)=\frac{(b-a)^2}{12},\quad F(x)=\frac{x-a}{b-a}$

PropertyFormulaNote
PDF$1/(b-a)$Constant — all values equally likely
CDF$(x-a)/(b-a)$Linear
Mean$(a+b)/2$Midpoint of interval
Variance$(b-a)^2/12$Width² / 12
Median$(a+b)/2$Same as mean (symmetric)
Entropy$\ln(b-a)$Maximum entropy for bounded support
SPECIAL ROLE: INVERSE CDF METHOD

Every CDF F(x) is uniform: if $X\sim F$, then $U=F(X)\sim U(0,1)$. Inverse: if $U\sim U(0,1)$, then $F^{-1}(U)\sim F$. This is the foundation of the inverse CDF method for random number generation — virtually all RNG in statistics uses this principle.

CLT FOR UNIFORM SUMS

Sum of $n$ independent $U(0,1)$: mean $= n/2$, variance $= n/12$. CLT: normalized sum $\to N(0,1)$ as $n\to\infty$. Famous approximation: sum of 12 $U(0,1)$ values minus 6 approximates $N(0,1)$ — the "12 uniform trick" for quick normal approximation.

Worked Example

Bus arrives uniformly at random in [0,30] minutes. Find P(wait > 10) and E[wait | wait > 10].

$P(X>10)=(30-10)/30=2/3\approx0.667$

$E[X\mid X>10]=E[U(10,30)]=(10+30)/2=20$ minutes.

Ross — A First Course in Probability, Ch. 5.1
DeGroot & Schervish — Probability and Statistics, Ch. 5.6
§4 FAQ
§5 Misconceptions & Common Errors
❌ Misconception 1

"Uniform means equally likely outcomes in every context — e.g., any roll on a loaded die is uniform."
The uniform distribution applies when outcomes on a continuous interval are equally likely. A loaded die is NOT uniform because some discrete outcomes are more probable. "Equally likely outcomes" applies to both discrete uniform (each of n outcomes has probability 1/n) and continuous uniform (constant density).

❌ Error 1

Var(U(a,b)) = (b-a)/12 instead of (b-a)²/12
✅ Variance = $(b-a)^2/12$. The squared range divided by 12. For U(0,1): Var=1/12≈0.0833. A common error is forgetting to square the range.
🔍 Computing (b-a)/12 instead of (b-a)²/12.

❌ Error 2

P(X = exact value) > 0 for continuous uniform
✅ For continuous distributions, P(X=c)=0 for any specific value c. The probability is only non-zero for intervals: P(x₁≤X≤x₂) = (x₂-x₁)/(b-a). This is a fundamental property of all continuous distributions.

Ross — A First Course in Probability, Ch. 5.1
DeGroot & Schervish — Ch. 5.6