Continuous distribution · also called rectangular
Uniform distribution
A value equally likely to fall anywhere between and : the position of a random cut, the phase of a wave, a round-off error. The standard uniform on is what random number generators produce, and every other distribution here can be sampled by transforming it.
Uniform probability calculator
P(X ≤ 1) = 0.5
At the parameters set by the sliders. The shaded region on the plot is the probability; the dots on the CDF mark F at its ends.
CDF
mean 1 · variance 0.3333 · sd 0.5774 · entropy 0.6931 nats
Formulas
| Parameters |
|
|---|---|
| Support | |
| CDF | |
| Mean | |
| Variance | |
| Mode | |
| MGF | |
| Entropy |
Worked example
A bus comes every 20 minutes and you arrive at a random time. What is the standard deviation of your wait?
The wait is Uniform, so its variance is and its standard deviation is minutes, around a mean of 10. answer checked by code
How it relates to others
- Limit← Discrete uniform: If is uniform on , tends to Uniform() as . checked by code
- Transformation→ Exponential: If is Uniform(), is Exponential(): the inverse-CDF method of sampling. checked by code
- Transformation→ Logistic: If is Uniform(), the log-odds is standard Logistic. checked by code
- Transformation→ Beta: The -th smallest of independent Uniform() values is Beta(). checked by code
- Special case← Beta: Beta() is Uniform(). checked by code
- Sum→ Triangular: The sum of two independent Uniform() variables is Triangular(). checked by code
- Transformation→ Arcsine: If is Uniform(), is Arcsine(). checked by code
- Special case← Kumaraswamy: Kumaraswamy() is Uniform(). checked by code
- Special case← Von Mises: Von Mises() is Uniform(): no preferred direction. checked by code
- Special case← Generalized Pareto: Generalized Pareto() is Uniform(). checked by code
All the relationships, as a diagram →
In Python
from scipy import stats
import numpy as np
X = stats.uniform(loc=0, scale=2)
X.pdf(0.5) # f(0.5) = 0.5
X.cdf(0.5) # P(X ≤ 0.5) = 0.25
X.mean(), X.var() # 1, 0.3333
X.ppf(0.95) # 95th percentile
X.rvs(size=10, random_state=0)
rng = np.random.default_rng(0)
rng.uniform(low=0, high=2, size=10)SciPy takes loc = a and scale = b − a, not the two ends.
Choosing between this and its neighbours? Which distribution for proportions and probabilities?