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.

PDF

00.20.4−4−20246f(x)mean

CDF

00.250.50.751−4−20246F(x)

mean 1 · variance 0.3333 · sd 0.5774 · entropy 0.6931 nats

Formulas

Parameters
  • , the lower end
  • , the upper end
Support
PDF
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

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?

← ZipfTriangular →