Introduction
The uniform random variable is one of the simplest and most fundamental probability distributions. It models a situation in which all outcomes in a given interval are equally likely. It’s often used as a building block for other distributions and is essential in simulations and Monte Carlo methods.
Definition
A uniform random variable can be either discrete or continuous. The most common and widely used is the continuous uniform distribution.
A continuous uniform random variable X
is said to be uniformly distributed over the interval [a, b]
, written as:
X ~ U(a, b)
This means that the probability of X
falling anywhere in the interval [a, b]
is equally likely.
Probability Density Function (PDF)
The PDF of a uniform distribution on [a, b]
is defined as:
f(x) = 1 / (b - a), for a ≤ x ≤ b
f(x) = 0, otherwise
This flat or constant density function indicates that all values in the interval [a, b]
are equally probable.
Cumulative Distribution Function (CDF)
The CDF, which gives the probability that X
is less than or equal to a certain value x
, is:
F(x) = 0 if x < a
F(x) = (x - a) / (b - a) if a ≤ x ≤ b F(x) = 1 if x > b
Mean and Variance
For X ~ U(a, b)
:
- Mean:
E[X] = (a + b) / 2
- Variance:
Var(X) = (b - a)2 / 12
Example
Suppose a bus arrives at a stop every 20 minutes. If you arrive at a random time, your waiting time X
is uniformly distributed between 0
and 20
minutes: X ~ U(0, 20)
.
– The probability that you wait less than 5 minutes:
P(X ≤ 5) = (5 - 0) / (20 - 0) = 5 / 20 = 0.25
– The average wait time:
E[X] = (0 + 20) / 2 = 10 minutes
Discrete Uniform Distribution
A discrete uniform distribution assigns equal probability to a finite set of n
outcomes. For example, rolling a fair 6-sided die produces outcomes {1, 2, 3, 4, 5, 6}
, each with probability 1/6
.
If X
is uniformly distributed over {x1, x2, ..., xn}
, then:
P(X = xi) = 1 / n for all i
Applications
- Random number generation
- Simulation and modeling in Monte Carlo methods
- Estimating probabilities in uniformly distributed data
- Game theory and lotteries
Python Code Example
from scipy.stats import uniform
Continuous uniform from a = 0 to b = 20
mean, var = uniform.mean(loc=0, scale=20), uniform.var(loc=0, scale=20) print("Mean:", mean) print("Variance:", var)
Probability of waiting less than 5 minutes
p = uniform.cdf(5, loc=0, scale=20) print("P(X ≤ 5):", p)
Conclusion
The uniform random variable is a foundational concept in probability and statistics. It models situations with equal likelihood and serves as a simple but powerful tool in data analysis and simulation. Whether dealing with continuous ranges or finite discrete sets, understanding uniform distributions helps establish deeper intuition for randomness and fair systems.