distribution #9
In this lesson

Wide tables, equations, and code scroll sideways. Swipe, or Tab to focus them and use the left and right arrow keys.

Uniform distribution

You will learn: Compute probabilities from interval lengths and inspect support boundaries.

Start with: Reading a distribution

Equal-length intervals inside [a,b] have equal probability. Every individual point has probability zero. The density is a flat rectangle with total area one.

f(x;a,b)=1b−aa≤x≤bf(x;a,b)=\frac{1}{b-a}\quad a\le x\le b
density by x00.20.40.60.811.200.20.40.60.81xdensity

Measure an interval by its overlap

The requested interval [0.2, 0.6] overlaps the support by 0.4000 units. Divide by total width 1.0000: P(0.2≤X≤0.6) = 0.400000. A single point has probability zero; endpoint inclusion makes no difference here.

Build a draw with the inverse CDF

Q(u)=a+(b−a)u = 0.250000. F(Q(u))=0.2500. Choosing u by hand explores a quantile. Drawing u uniformly on (0,1) generates the model. The controls at zero and one show the limiting endpoints.

Solid line: PDF = 1/(b−a) = 1.000 on [0.0, 1.0]. Mean = 0.50, Std = 0.29. Dashes: mean. 500 samples.

What to notice

  • Move a or b and the height adjusts so the area stays exactly 1 — the PDF scales as 1/(b−a).
  • The mean E[X]=a+b2E[X]=\frac{a+b}{2} sits at the midpoint. The variance Var(X)=(b−a)212\text{Var}(X)=\frac{(b-a)^2}{12} depends only on the width, not the location.
  • Even this maximally flat distribution produces a histogram that looks roughly uniform — but average several uniforms together and the histogram rapidly becomes bell-shaped.

Generating other distributions

The uniform distribution is the foundation of random number generation. A uniform(0,1) sample u can be transformed into any other distribution via its inverse CDF: if F is the CDF of the target distribution, then F⁻¹(u) has that target distribution. This is the inverse transform method, and it’s how many of the samplers on this site work.

Connection to the Central Limit Theorem

Sum n independent uniform draws and divide by n. At n=3 or n=4 the distribution already has a rounded center, but it is not normal and its support remains bounded. By the Central Limit Theorem this is expected — standardized sums of i.i.d. variables with finite positive variance converge in distribution to a standard normal. The uniform is a popular illustration because the starting shape is maximally unlike a bell curve.

Review the distribution-reading guide to compare continuous CDFs with discrete and empirical steps, then read them backwards as quantiles.

A probability is an area, not a height

For Uniform(0,1), the interval [0.2,0.6] has length 0.4 and probability 0.4. Moving its lower endpoint to −0.2 does not add probability below zero: only [0,0.6] overlaps the support, giving 0.6. An interval entirely outside the bounds has probability zero.

For Uniform(2,5), the interval [2.5,4] has probability 1.5/3=0.5. The density is 1/3 per unit, the mean is 3.5, and the variance is 9/12=0.75. If both interval endpoints are 3.5, the area is zero even though the density there is positive. Narrow bounds can produce density heights above one without producing probabilities above one.

Invert the cumulative scale

Within the support, F(x)=(x−a)/(b−a). Solving u=F(x) gives Q(u)=a+(b−a)u. At a=2, b=5 and u=0.25, the quantile is 2.75. One quarter of the model’s probability lies at or below that cutoff. The controls show this deterministic mapping; a random draw additionally requires a uniform random input.

A flat model encodes a choice of bounds and measurement scale. If X is uniform on [0,1], then Y=X² is not uniform: P(Y≤0.25)=P(X≤0.5)=0.5, rather than 0.25. Flatness does not survive an arbitrary transformation, and ignorance about a quantity does not by itself choose its bounds or scale.

Make a prediction

A waiting time is known to be between zero and ten minutes. Does that information establish a uniform distribution?

Explore the answer

No. The bounds specify what is possible, but not how probability is allocated inside them. Equal-length intervals could have very different chances. A uniform model needs that extra assumption, and changing the bounds changes its predictions.

Reference

Random Services: continuous uniform distribution gives the density, cumulative law, quantile, and moments. Compare an explicitly elicited mode in the triangular distribution before treating bounded uncertainty as flat.

Reset all settings