Uniform Distribution
The uniform distribution spreads probability evenly, and its continuous form is the root of most random number generation.
Discrete uniform
A discrete uniform distribution assigns equal probability 1/n to each of n outcomes. A fair die is the canonical case with n = 6 and p(x) = 1/6. Its mean is the midpoint of the values and its variance depends only on the range.
Continuous uniform
The continuous uniform on [a, b] has constant density f(x) = 1/(b − a) inside the interval and zero outside. Its mean is (a + b)/2 and its variance is (b − a)²/12. The standard uniform on [0, 1] is the most important special case.
The foundation of sampling
Pseudorandom generators produce approximately standard-uniform values, and every other distribution is built from them — by inverse-transform sampling, rejection, or specialized algorithms. If X = F⁻¹(U) with U uniform, then X follows the distribution with CDF F. The quality of a Monte Carlo study rests on the quality of this uniform stream.
Maximum entropy on an interval
Among all distributions supported on a bounded interval, the uniform has the largest entropy. It is the least-informative choice when only the range is known, which makes it a natural non-informative prior for a bounded parameter.
import random
samples = [random.uniform(2,5) for _ in range(100000)]
print(round(sum(samples)/len(samples),3)) # near 3.5
Uniform variates over a lattice are also the basis for quasi-random (low-discrepancy) sequences that can converge faster than plain Monte Carlo.