Uniform distribution
In probability theory and statistics, the uniform distribution is a family of symmetric probability distributions in which every outcome or interval within a specified finite or continuous support has an equal probability of occurrence, making it a fundamental reference distribution for modeling equally likely events.[1] It encompasses both discrete and continuous forms, with the continuous variant often serving as a baseline for more complex distributions due to its simplicity and lack of bias toward any particular value in the range.[2] The continuous uniform distribution, denoted U(a, b) where a < b are real numbers defining the interval, has a probability density function given by f(x) = \frac{1}{b - a} for a \leq x \leq b, and f(x) = 0 otherwise.[3] This ensures the total probability integrates to 1 over the interval, with the mean (expected value) at \frac{a + b}{2} and the variance at \frac{(b - a)^2}{12}.[1] A special case is the standard uniform distribution on [0, 1], which is pivotal for generating random variables from other distributions via transformation methods.[4] The discrete uniform distribution applies to a finite set of equally likely outcomes, such as the integers from a to b inclusive, where each has probability mass p(x) = \frac{1}{b - a + 1}.[5] For the common case of outcomes from 1 to n, the probability mass function is p(x) = \frac{1}{n} for x = 1, 2, \dots, n, the mean is \frac{n + 1}{2}, and the variance is \frac{n^2 - 1}{12}.[6] Notable applications of the uniform distribution include random number generation in computational simulations, where it underpins pseudorandom sequences essential for Monte Carlo methods.[1] It also models scenarios with inherent uniformity, such as random sampling in surveys, assignment of treatments in randomized experiments, and approximations for physical processes like bus arrival times under ideal conditions.[7] In order statistics and reliability engineering, uniform assumptions facilitate analysis of extremes and spacings in data sets.[8]Overview
Definition
In probability theory, the uniform distribution is a probability distribution that assigns equal probability to every outcome within a specified finite set or bounded interval, modeling scenarios where no outcome is preferred over another due to symmetry.[9] This concept presupposes familiarity with fundamental elements of probability, including the sample space as the collection of all possible outcomes and the uniform assignment of probabilities to events or subsets thereof.[9][5] Uniform distributions manifest in two primary forms: discrete and continuous. The discrete uniform distribution arises in cases with a finite or countably infinite sample space, where each discrete outcome receives identical probability weight.[10] A classic example is the flip of a fair coin, which yields a discrete uniform distribution over the two equally likely outcomes of heads or tails.[9] Conversely, the continuous uniform distribution applies to uncountable outcomes spanning a continuous interval, ensuring that probabilities are proportionally equal across subintervals of the same length.[2] For instance, choosing a random point on a line segment from 0 to 1 exemplifies this, as every point or equal-length subsegment is equally probable.[9] The mean and variance serve as key measures of central tendency and spread for uniform distributions.[9]Historical development
The concept of equal likelihood in probabilistic outcomes traces its origins to the 17th century, particularly through the correspondence between Blaise Pascal and Pierre de Fermat in 1654, who analyzed problems in games of chance such as dice and card games, assuming uniform probability across possible results to resolve disputes like the "problem of points."[11][12] This foundational work laid the groundwork for treating discrete outcomes as equiprobable in fair games, marking an early implicit recognition of the discrete uniform distribution.[13] In the early 18th century, Jacob Bernoulli advanced this idea in his seminal 1713 work Ars Conjectandi, where he formalized equiprobability for discrete cases in the context of games and the law of large numbers, treating outcomes like coin tosses or dice rolls as having equal probability under fairness assumptions.[14] Later that century, Abraham de Moivre contributed to continuous extensions by developing approximations for discrete probabilities and introducing a uniform model for remaining lifetime in actuarial contexts, known as de Moivre's law, which posits a uniform distribution over a finite interval to represent equal mortality risk.[15] The 19th century saw further refinement through Pierre-Simon Laplace's integral formulations of probability, where he employed uniform distributions as priors in Bayesian inference and for modeling errors, emphasizing the principle of insufficient reason to assign equal probabilities across continuous intervals.[16] This culminated in Andrey Kolmogorov's 1933 axiomatic foundation of probability theory, which integrated measure-theoretic approaches and solidified the uniform distribution—particularly the continuous uniform on [0,1]—as a core element by normalizing Lebesgue measure to define probability spaces rigorously.[17] Post-1940s developments in computational statistics elevated the uniform distribution's role, driven by the need for pseudorandom number generators to simulate uniform deviates on computers, with early electronic methods emerging in the late 1940s to produce sequences approximating the continuous uniform for Monte Carlo simulations.[18] These advancements recognized discrete and continuous uniform variants as essential building blocks for generating more complex distributions in statistical computing.[19]Discrete uniform distribution
Probability mass function
The probability mass function (PMF) of a discrete uniform distribution describes the probability of each possible outcome when all outcomes in a finite set are equally likely. For a random variable X that takes integer values from a to b inclusive, where a and b are integers with a \leq b, the PMF is defined as P(X = x) = \frac{1}{b - a + 1}, \quad x = a, a+1, \dots, b. This formula arises because there are exactly b - a + 1 possible outcomes, each assigned equal probability to ensure the total probability sums to 1: \sum_{x=a}^{b} P(X = x) = (b - a + 1) \cdot \frac{1}{b - a + 1} = 1. A common special case occurs when the outcomes are labeled from 1 to n, yielding P(X = k) = \frac{1}{n} for k = 1, 2, \dots, n. For example, the outcome of rolling a fair six-sided die follows this distribution, with P(X = k) = \frac{1}{6} for each face k = 1 to $6. While the discrete uniform distribution is well-defined only for finite support, attempts to extend it to an infinite countable set, such as all integers, result in an improper distribution where the probabilities cannot sum to 1, as each would need to be zero to avoid divergence. The PMF can be visualized as a bar graph with equal-height bars at each integer outcome within the support, reflecting the uniform probability assignment. In the limit as the number of discrete points increases and the spacing approaches zero, the discrete uniform PMF converges to the probability density function of the continuous uniform distribution.Statistical properties
The discrete uniform distribution exhibits symmetry around its mean, which is located at (n+1)/2 for outcomes ranging from 1 to n, making the probabilities mirror each other equidistant from the center.[20] This property holds for both even and odd n, though the exact centering differs slightly—for even n, no single point lies at the mean, while for odd n, the middle value does.[20] Since all outcomes have equal probability, the distribution lacks a unique mode; every value in the support serves as a mode.[20] The Shannon entropy of the discrete uniform distribution measures its maximum uncertainty among distributions over n outcomes, given by H(X) = \log_2 n bits.[21] For example, a fair six-sided die (n=6) has entropy \log_2 6 \approx 2.585 bits, higher than a biased die where one face has probability 0.5 and the others share the rest equally, yielding lower entropy due to reduced uncertainty.[21] The probability generating function is G(s) = \frac{1 - s^n}{n(1 - s)} for s \neq 1, which simplifies to \frac{s(1 - s^n)}{n(1 - s)} when outcomes start from 1.[20] The discrete uniform distribution arises as a special case of the multinomial distribution with a single trial and equal probabilities across categories, equivalent to the uniform categorical distribution.[22]Continuous uniform distribution
Probability density function
The probability density function (PDF) of a continuous uniform random variable X \sim U(a, b), where a < b, describes a distribution where every value in the interval [a, b] is equally likely. The PDF is defined as f(x) = \begin{cases} \frac{1}{b - a} & a \leq x \leq b, \\ 0 & \text{otherwise}. \end{cases} [3][23] This constant density arises from the requirement that the total probability over the support [a, b] must equal 1, as mandated for any valid PDF. Integrating the function over the interval yields \int_a^b \frac{1}{b - a} \, dx = 1, confirming the height \frac{1}{b - a} produces a rectangular area of unit measure. The uniform density thus represents an even spread of probability mass, analogous to a rod of uniform material density where mass is proportional to length.[3][23] A special case is the standard uniform distribution U(0, 1), where the PDF simplifies to f(x) = 1 for $0 \leq x \leq 1, and 0 otherwise; this serves as a foundational building block in probability theory and random number generation.[3] The PDF's rectangular shape visually emphasizes uniformity: a flat line at height \frac{1}{b - a} between a and b, dropping to zero outside, with probabilities computed as the area under this curve over subintervals. For instance, if X \sim U(0, 10), the probability P(2 \leq X \leq 5) is the integral from 2 to 5, equaling \frac{3}{10}, reflecting the subinterval length relative to the full interval.[3][23]Cumulative distribution function
The cumulative distribution function (CDF) of a continuous uniform random variable X \sim U(a, b), where a < b, is defined as F(x) = P(X \leq x). It is given by the piecewise function: F(x) = \begin{cases} 0 & \text{if } x < a, \\ \frac{x - a}{b - a} & \text{if } a \leq x \leq b, \\ 1 & \text{if } x > b. \end{cases} [3][24][25] This CDF is derived by integrating the probability density function (PDF) from -\infty to x: F(x) = \int_{-\infty}^x f(t) \, dt, where f(t) = \frac{1}{b - a} for a \leq t \leq b and 0 otherwise. For a \leq x \leq b, the integral evaluates to \int_a^x \frac{1}{b - a} \, dt = \frac{x - a}{b - a}, producing a linear increase from 0 at x = a to 1 at x = b.[24] The CDF exhibits key properties: it is non-decreasing overall, strictly increasing and piecewise linear between a and b with slope \frac{1}{b - a}, and continuous everywhere, ranging from 0 to 1 asymptotically.[3][26] The quantile function, or inverse CDF, is obtained by solving F(x_p) = p for x_p where p \in [0,1], yielding x_p = a + p(b - a). This provides the value at which the CDF reaches probability p.[24] For the standard uniform distribution U(0,1), the CDF simplifies to F(x) = x for $0 \leq x \leq 1, so F(0.5) = 0.5, which corresponds to the median of the distribution.[3]Moments and characteristics
Expected value and variance
The expected value, or mean, of a discrete uniform distribution over the integers from 1 to n, denoted U(1,n), is \mu = \frac{n+1}{2}.[27] This represents the arithmetic average of the possible outcomes, serving as the midpoint of the support. For the continuous uniform distribution over the interval [a, b], where a < b, the mean is \mu = \frac{a + b}{2}.[28] The mean for the continuous case can be derived from the definition of expectation: E[X] = \int_{a}^{b} x \cdot \frac{1}{b - a} \, dx = \frac{1}{b - a} \left[ \frac{x^2}{2} \right]_{a}^{b} = \frac{b^2 - a^2}{2(b - a)} = \frac{(b - a)(b + a)}{2(b - a)} = \frac{a + b}{2}. [29] The variance of the discrete uniform distribution U(1,n) is \sigma^2 = \frac{n^2 - 1}{12}.[27] For the continuous uniform distribution U(a,b), the variance is \sigma^2 = \frac{(b - a)^2}{12}.[28] This formula quantifies the average squared deviation from the mean, measuring the distribution's spread across the support interval. To derive the continuous variance, first compute the second raw moment: E[X^2] = \int_{a}^{b} x^2 \cdot \frac{1}{b - a} \, dx = \frac{1}{b - a} \left[ \frac{x^3}{3} \right]_{a}^{b} = \frac{b^3 - a^3}{3(b - a)} = \frac{(b - a)(a^2 + ab + b^2)}{3(b - a)} = \frac{a^2 + ab + b^2}{3}. Then, apply the variance formula: \text{Var}(X) = E[X^2] - (E[X])^2 = \frac{a^2 + ab + b^2}{3} - \left( \frac{a + b}{2} \right)^2 = \frac{a^2 + ab + b^2}{3} - \frac{a^2 + 2ab + b^2}{4} = \frac{(b - a)^2}{12}. [29] The mean acts as the central location or midpoint of the uniform support, while the variance captures the even spread of probability mass, with the factor of 12 arising from the integration over the fixed interval. For example, the standard uniform distribution U(0,1) has mean 0.5 and variance \frac{1}{12} \approx 0.083.[28] Higher moments, such as skewness, are zero for these symmetric distributions.Higher moments
The central moments of a uniform distribution reflect its symmetry about the mean. For both continuous and discrete cases, all odd-order central moments are zero due to this symmetry.[30][28] The skewness, defined as the third standardized central moment, is therefore always zero for symmetric uniform distributions.[30][1] For the continuous uniform distribution on [a, b], the fourth central moment is given by E[(X - \mu)^4] = \frac{(b - a)^4}{80}, where \mu = (a + b)/2 is the mean.[28] This leads to a kurtosis of \frac{9}{5} = 1.8.[1][30] The kurtosis value below 3 indicates a platykurtic distribution with thinner tails than the normal distribution, implying fewer extreme outliers relative to a normal distribution with the same variance.[30] The raw moments of order k for the continuous uniform distribution on [a, b] are E[X^k] = \frac{b^{k+1} - a^{k+1}}{(k+1)(b - a)}. [28] For example, with the standard uniform distribution on [0, 1], the third raw moment is E[X^3] = \frac{1}{4} (though the corresponding central moment is 0), and the fourth raw moment is E[X^4] = \frac{1}{5}.[28] In the discrete uniform distribution over \{1, 2, \dots, n\}, odd central moments are similarly zero due to symmetry.[27] The kurtosis exhibits patterns analogous to the continuous case and approaches \frac{9}{5} as n becomes large.[27]Sampling and inference
Random number generation
Generating pseudorandom numbers from a uniform distribution is fundamental to Monte Carlo simulations and statistical computing, where high-quality uniform variates serve as the basis for sampling more complex distributions. Early efforts in this area include John von Neumann's middle-square method, developed in 1946 and presented at a 1949 symposium on computing machinery, which generates pseudorandom digits by squaring an n-digit seed and extracting the middle n digits of the result.[31] This approach, while pioneering, suffered from short periods and poor uniformity, leading to its replacement by more robust algorithms.[32] For the discrete uniform distribution over integers from 1 to n, a standard method to avoid bias uses rejection sampling with modular arithmetic on output from a pseudorandom bit generator. Specifically, generate U uniformly in [0, m) where m is large (e.g., power of 2); let q = \lfloor m / n \rfloor, r = m \mod n; if U < q n, set X = \lfloor U / q \rfloor \mod n + 1; otherwise, reject and repeat. This ensures exact uniformity.[33][34] Generating continuous uniform variates on [0,1) typically relies on pseudorandom number generators (PRNGs) that produce sequences approximating this distribution. Linear congruential generators (LCGs), defined by the recurrence X_{i+1} = (a X_i + c) \mod m with normalized output U_i = X_i / m, are simple and widely implemented due to their efficiency.[35] For superior statistical properties and a period of $2^{19937} - 1, the Mersenne Twister algorithm, introduced by Matsumoto and Nishimura in 1998, has become a standard, offering equidistribution in up to 623 dimensions.[36] To obtain a uniform variate on [a, b), apply the affine transformation X = a + (b - a) U where U \sim \text{Uniform}(0,1).[37] Uniform pseudorandom numbers on [0,1) also form the foundation of inverse transform sampling for generating variates from arbitrary distributions. In this method, if F is the cumulative distribution function of the target distribution, then X = F^{-1}(U) where U \sim \text{Uniform}(0,1) produces a sample from the target, leveraging the uniformity to match the desired probabilities.[37] This technique is particularly valuable in simulations requiring non-uniform samples, such as Monte Carlo integration for parameter estimation.[34] The quality of uniform random number generators is assessed through metrics like period length, which measures the cycle before repetition (ideally approaching $2^k for k-bit outputs), and statistical tests for uniformity and independence. The chi-squared goodness-of-fit test, for instance, evaluates whether observed frequencies in binned samples deviate significantly from expected uniform proportions, with low p-values indicating poor uniformity.[38] Comprehensive suites like TestU01 apply such tests to detect correlations or lattice structures in the sequence.[38] In practice, programming languages provide built-in implementations; for example, Python'srandom.uniform(a, b) function uses the Mersenne Twister PRNG to generate a float in [a, b] via the scaling transformation on its core uniform generator.[39] This method ensures reproducibility with a fixed seed while maintaining high-quality output for most applications.[39]