VISUAL LESSON · 6 PICTURES

Uniform Distribution

What is the mathematical foundation of uniform distribution?

Progress stays on this device · no login
BEFORE THE FIRST PICTURE

How this lesson unfolds.

Begin with How do programming libraries like Python and PyTorch generate arbitrary continuous uniform variables from a standard pseudo-random generator? The sequence then connects Geometry of Probability: Area Under the Uniform Curve and builds toward Deriving the Variance: Where Does the Number 12 Come From?.

Picture 1 of 6 · tap to inspect in full resolution
01

How do programming libraries like Python and PyTorch generate arbitrary continuous uniform variables from a standard pseudo-random generator?

INTUITION

Every continuous random generator starts as a unit ruler [0, 1]; stretching the ruler by width (b - a) and sliding it to start at a produces any uniform distribution on Earth.

MATHEMATICAL STATEMENTS
  1. $$U \sim \text{Uniform}(0, 1) \implies X = a + (b - a)U \sim \text{Uniform}(a, b), \quad f_X(x) = \frac{1}{b - a}$$
  2. $$Standard random engines output a uniform float U in [0, 1); an affine transformation X = a + (b - a)*U stretches and shifts this base variable to cover any target continuous interval [a, b].$$
✦ More context & mechanics
Conceptual Mechanics & Logic

Modern computational systems implement random sampling using algorithms like the Mersenne Twister or PCG, generating pseudo-random integers mapped to floating-point numbers in the standard interval U ~ Uniform(0, 1). To sample from Uniform(a, b), we apply the linear map X = a + (b - a)*U. Because the transformation is strictly monotonic, probability density is preserved uniformly across the new width (b - a), guaranteeing that every subinterval of equal length within [a, b] has an identical probability of occurrence.

Real-World Usage

Machine learning weight initialization (e.g., Xavier/Glorot uniform initialization in PyTorch) draws initial neural network weights uniformly from [-1/sqrt(d), 1/sqrt(d)] to prevent vanishing and exploding gradients during forward passes.

History / Origin Story

John von Neumann introduced the first pseudo-random number generator (the middle-square method) in 1946 for Monte Carlo calculations at Los Alamos, recognizing the uniform distribution as the mother of all computational stochasticity.

How to Memorize

'Scale and Shift' — multiply unit random U by span (b - a), then add baseline a: X = a + (b - a)*U.

Picture 2 of 6 · tap to inspect in full resolution
02

If a bus arrives uniformly between 10 and 30 minutes, what is the exact probability that it arrives between 15 and 22 minutes?

INTUITION

In a uniform distribution, calculus simplifies into elementary school geometry: probability is literally width times height.

MATHEMATICAL STATEMENTS
  1. $$P(c \le X \le d) = \int_c^d \frac{1}{b - a}\,dx = \frac{d - c}{b - a}$$
  2. $$Because the uniform density is flat with height 1/(30 - 10) = 1/20, the probability is simply the rectangle area: width (22 - 15) multiplied by height 0.05, yielding 0.35 (35%).$$
✦ More context & mechanics
Conceptual Mechanics & Logic

Let X be the bus arrival time, where X ~ Uniform(10, 30). The total support width is b - a = 30 - 10 = 20 minutes. To satisfy the total probability axiom (total area = 1), the constant height must be f(x) = 1/(b - a) = 1/20 = 0.05 min^(-1). To find P(15 <= X <= 22), we evaluate the integral of the constant density over [15, 22]: P(15 <= X <= 22) = int_15²2 (1/20) dx = (22 - 15) / 20 = 7/20 = 0.35. Geometric area directly equals probability mass.

Real-World Usage

Airport ground operations and ride-hailing dispatch algorithms (e.g., Uber/Lyft pickup estimates) model arrival delays within guaranteed time windows to compute SLA violation probabilities.

History / Origin Story

Thomas Bayes and Pierre-Simon Laplace utilized the continuous uniform distribution in the 18th century as the 'principle of insufficient reason' (flat prior) when no prior knowledge favored one outcome over another.

How to Memorize

'Target Width over Total Width' — for any uniform interval [c, d] inside [a, b], P = (d - c) / (b - a).

Picture 3 of 6 · tap to inspect in full resolution
03

Why is the density height of a continuous uniform distribution strictly locked to 1/(b - a) rather than any arbitrary positive number?

INTUITION

Total probability is a fixed lump of clay equal to 1; if you roll it out uniformly across length (b - a), its thickness is mechanically determined.

MATHEMATICAL STATEMENTS
  1. $$\int_a^b f(x)\,dx = 1 \implies h(b - a) = 1 \implies f(x) = \frac{1}{b - a} \quad (x \in [a, b])$$
  2. $$Total probability over the entire support must equal 1; since the support width is (b - a) and the density height h is constant, h * (b - a) = 1 forces h = 1/(b - a).$$
✦ More context & mechanics
Conceptual Mechanics & Logic

By definition, a uniform distribution assigns equal likelihood to equal subintervals. This implies that the density f(x) cannot fluctuate; it must be a constant value h across the support [a, b], and 0 elsewhere. By Kolmogorov's second axiom, the total probability across all possible real outcomes must equal 1: int_(-inf)^inf f(x) dx = int_a^b h dx = h * (b - a) = 1. Solving for h gives h = 1 / (b - a). If the support width doubles, the height must halve to preserve total probability.

Real-World Usage

Cryptographic hashing functions and random salt generators spread entropy uniformly across 256-bit key spaces to maximize uncertainty and ensure no individual cryptographic key bucket has higher collision probability.

History / Origin Story

Andrei Kolmogorov codified the normalization axiom int f(x)dx = 1 in 'Grundbegriffe der Wahrscheinlichkeitsrechnung' (1933), solidifying modern axiomatic probability.

How to Memorize

'Unit Area Dictates Height' — width times height is 1, so height is always 1 over width: f(x) = 1/(b - a).

Picture 4 of 6 · tap to inspect in full resolution
04

What is the defining structural property that distinguishes a continuous uniform distribution from all other continuous distributions?

INTUITION

A uniform distribution is completely democratic; no location on the interval receives favoritism, bias, or special treatment.

MATHEMATICAL STATEMENT
  1. $$P(x_1 \le X \le x_1 + w) = P(x_2 \le X \le x_2 + w) = \frac{w}{b - a} \quad \forall [x_i, x_i + w] \subseteq [a, b]$$
  • Learning goalDemonstrate translation invariance of uniform interval probabilities across support domains.
  • Helpful foundationsSubintervals · Translation invariance · Probability density
  • Common trapEqual probabilities maximize unpredictability and information entropy rather than producing predictable outcomes.
  • Next connectionDerive the expected value midpoint of a continuous uniform distribution.
✦ More context & mechanics
Conceptual Mechanics & Logic

For any continuous random variable X ~ Uniform(a, b) and any width w > 0, consider two distinct intervals [x₁, x₁ + w] and [x₂, x₂ + w] lying completely within [a, b]. The probability of landing in the first is w / (b - a), and the probability of landing in the second is w / (b - a). Because the density function is horizontal and featureless, the probability depends solely on the interval length w, not its coordinate position. This translation invariance characterizes maximum ignorance or uniform spatial dispersion.

Real-World Usage

Round-robin load scheduling in distributed cloud architectures (e.g., Kubernetes pods) uses uniform random selection to ensure CPU traffic is evenly dispersed without creating hot spots.

History / Origin Story

Claude Shannon's 1948 information theory proved that among all continuous distributions bounded on [a, b], the Uniform distribution achieves maximum differential entropy (maximum uncertainty).

How to Memorize

'Same Width, Same Odds' — if interval lengths match, their probabilities match.

Picture 5 of 6 · tap to inspect in full resolution
05

How is the expected value of a continuous uniform distribution derived from first principles using calculus?

INTUITION

Because the distribution is perfectly symmetric, its physical center of balance must sit exactly halfway between its endpoints.

MATHEMATICAL STATEMENTS
  1. $$E[X] = \int_a^b x \left(\frac{1}{b - a}\right) dx = \frac{b^2 - a^2}{2(b - a)} = \frac{a + b}{2}$$
  2. $$Integrating x*f(x) over [a, b] produces (b^2 - a^2) / (2(b - a)), which factors cleanly into the arithmetic midpoint: E[X] = (a + b) / 2.$$
  • Learning goalDerive the expectation of a continuous uniform random variable using definite integration.
  • Helpful foundationsIntegration of polynomials · Difference of squares · Center of mass
  • Common trapContinuous expectation replaces summation with integration over density: E[X] = ∫ x f(x) dx.
  • Next connectionDerive uniform distribution variance and investigate denominator 12.
✦ More context & mechanics
Conceptual Mechanics & Logic

By the continuous definition of expectation, E[X] = int_(-inf)^inf x f(x) dx. Substituting the uniform PDF f(x) = 1/(b - a) on [a, b]: E[X] = (1 / (b - a)) int_a^b x dx = (1 / (b - a)) * [x² / 2]_a^b = (b² - a²) / (2(b - a)). Factoring the numerator as a difference of squares: (b - a)(b + a) / (2(b - a)). Canceling (b - a) leaves E[X] = (a + b) / 2. For the bus arriving between 10 and 30 minutes, E[X] = (10 + 30) / 2 = 20 minutes.

Real-World Usage

Financial option pricing models (such as Monte Carlo strike simulations) use expected midpoint values to center payoff distributions when evaluating European binary contracts.

History / Origin Story

Pierre-Simon Laplace formalized continuous integration for centers of mass and probability expectations in 'Theorie analytique des probabilites' (1812), showing expectation is mathematically equivalent to the centroid of a physical laminar plate.

How to Memorize

'Average of the Extremes' — the mean of Uniform(a, b) is simply the average of its boundaries: (a + b)/2.

Picture 6 of 6 · tap to inspect in full resolution
06

Why does the variance of a continuous uniform distribution contain the surprising divisor 12: Var(X) = (b - a)² / 12?

INTUITION

The divisor 12 is the algebraic collision between the integral of x² (which brings a factor of 1/3) and the square of the mean (which brings a factor of 1/4): 1/3 - 1/4 = 1/12.

MATHEMATICAL STATEMENTS
  1. $$\text{Var}(X) = E[X^2] - (E[X])^2 = \frac{a^2 + ab + b^2}{3} - \frac{(a + b)^2}{4} = \frac{(b - a)^2}{12}$$
  2. $$Evaluating E[X^2] yields (a^2 + ab + b^2)/3, and subtracting (E[X])^2 = (a+b)^2/4 results in a common denominator of 12, leaving Var(X) = (b - a)^2 / 12.$$
  • Learning goalDerive Uniform(a, b) variance from second moments and explain denominator 12.
  • Helpful foundationsSecond moments · Difference of cubes · Variance formula
  • Common trapVariance has squared physical units; standard deviation requires taking the square root.
  • Next connectionContrast PMF, PDF, and cumulative distribution functions across domains.
✦ More context & mechanics
Conceptual Mechanics & Logic

Variance is defined as Var(X) = E[X²] - (E[X])². First compute the second moment: E[X²] = int_a^b x² (1 / (b - a)) dx = (1 / (b - a)) [x³ / 3]_a^b = (b³ - a³) / (3(b - a)). Factoring the difference of cubes: (b - a)(a² + ab + b²) / (3(b - a)) = (a² + ab + b²) / 3. Next, subtract the square of the mean: (E[X])² = ((a + b)/2)² = (a² + 2ab + b²) / 4. Finding a common denominator of 12: [4(a² + ab + b²) - 3(a² + 2ab + b²)] / 12 = (a² - 2ab + b²) / 12 = (b - a)² / 12. For the bus interval [10, 30], Var(X) = (30 - 10)² / 12 = 400 / 12 = 33.33 min², giving standard deviation sigma = sqrt(33.33) = 5.77 minutes.

Real-World Usage

Analog-to-digital converters (ADC) and digital signal processors introduce quantization noise modeled as Uniform(-Delta/2, Delta/2); the signal-to-noise ratio formula (SNR = 6.02 * N + 1.76 dB) is derived directly from this Delta² / 12 variance.

History / Origin Story

Abraham de Moivre established early moment calculations in 'The Doctrine of Chances' (1718), demonstrating how polynomial integrations systematically produce fractional factorial denominators.

How to Memorize

'Spread Squared over Twelve' — the variance of Uniform(a, b) is always (width)² / 12.