Uniform Distribution
What is the mathematical foundation of uniform distribution?
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?.
How do programming libraries like Python and PyTorch generate arbitrary continuous uniform variables from a standard pseudo-random generator?
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.
- $$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}$$
- $$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].$$
- Learning goalMap standard uniform variables onto arbitrary continuous intervals computationally.
- Helpful foundationsLinear transformations · Pseudo-random generation · Uniform interval · Foundations of the Theory of Probability (Andrey Kolmogorov, 1933) · An Essay towards solving a Problem in the Doctrine of Chances (Thomas Bayes, 1763)
- Common trapContinuous uniform generators return floating-point real numbers, not discrete values.
- Next connectionCalculate bus arrival probabilities using geometric rectangular areas.
More context & mechanics
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.
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.
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.
'Scale and Shift' — multiply unit random U by span (b - a), then add baseline a: X = a + (b - a)*U.
If a bus arrives uniformly between 10 and 30 minutes, what is the exact probability that it arrives between 15 and 22 minutes?
In a uniform distribution, calculus simplifies into elementary school geometry: probability is literally width times height.
- $$P(c \le X \le d) = \int_c^d \frac{1}{b - a}\,dx = \frac{d - c}{b - a}$$
- $$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%).$$
- Learning goalCompute uniform interval probabilities by evaluating rectangular geometric area.
- Helpful foundationsArea of a rectangle · Uniform support · Integration of a constant · Foundations of the Theory of Probability (Andrey Kolmogorov, 1933) · An Essay towards solving a Problem in the Doctrine of Chances (Thomas Bayes, 1763)
- Common trapHeight f(x) is probability density; probability requires multiplying density by interval width.
- Next connectionExplain why probability axioms force uniform density height to 1/(b - a).
More context & mechanics
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.
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.
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.
'Target Width over Total Width' — for any uniform interval [c, d] inside [a, b], P = (d - c) / (b - a).
Why is the density height of a continuous uniform distribution strictly locked to 1/(b - a) rather than any arbitrary positive number?
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.
- $$\int_a^b f(x)\,dx = 1 \implies h(b - a) = 1 \implies f(x) = \frac{1}{b - a} \quad (x \in [a, b])$$
- $$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).$$
- Learning goalProve that normalization uniquely determines the continuous uniform density height.
- Helpful foundationsNormalization condition · Definite integration · Support bounds · Foundations of the Theory of Probability (Andrey Kolmogorov, 1933) · An Essay towards solving a Problem in the Doctrine of Chances (Thomas Bayes, 1763)
- Common trapProbability density can exceed 1 freely as long as its total integral equals 1.
- Next connectionVerify that equal interval widths produce equal probability.
More context & mechanics
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.
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.
Andrei Kolmogorov codified the normalization axiom int f(x)dx = 1 in 'Grundbegriffe der Wahrscheinlichkeitsrechnung' (1933), solidifying modern axiomatic probability.
'Unit Area Dictates Height' — width times height is 1, so height is always 1 over width: f(x) = 1/(b - a).
What is the defining structural property that distinguishes a continuous uniform distribution from all other continuous distributions?
A uniform distribution is completely democratic; no location on the interval receives favoritism, bias, or special treatment.
- $$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
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.
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.
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).
'Same Width, Same Odds' — if interval lengths match, their probabilities match.
How is the expected value of a continuous uniform distribution derived from first principles using calculus?
Because the distribution is perfectly symmetric, its physical center of balance must sit exactly halfway between its endpoints.
- $$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}$$
- $$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
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.
Financial option pricing models (such as Monte Carlo strike simulations) use expected midpoint values to center payoff distributions when evaluating European binary contracts.
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.
'Average of the Extremes' — the mean of Uniform(a, b) is simply the average of its boundaries: (a + b)/2.
Why does the variance of a continuous uniform distribution contain the surprising divisor 12: Var(X) = (b - a)² / 12?
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.
- $$\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}$$
- $$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
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.
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.
Abraham de Moivre established early moment calculations in 'The Doctrine of Chances' (1718), demonstrating how polynomial integrations systematically produce fractional factorial denominators.
'Spread Squared over Twelve' — the variance of Uniform(a, b) is always (width)² / 12.