Math glossary

Uniform Distribution: Formulas and Worked Probability Examples

Use discrete and continuous uniform formulas for probabilities, mean, variance, and percentiles. Follow six worked examples.

TL;DR

A uniform distribution gives equal probability to equal-sized choices. In the discrete case, each outcome has probability 1/n1/n. In the continuous case, divide the interval length you want by the total interval length.

Key Points

  • A discrete uniform model assigns equal mass to each possible outcome.
  • A continuous uniform model on [a,b][a,b] has constant density 1/(b−a)1/(b-a) for a<ba<b.
  • The continuous uniform mean is (a+b)/2(a+b)/2, and its variance is (b−a)2/12(b-a)^2/12.
  • For a continuous model, the probability of any exact point is zero.
  • Find interval probabilities using only the part of the requested interval inside the model’s support.

What is a uniform distribution?

A uniform distribution spreads probability evenly over its possible outcomes. If outcomes are separate, like the faces of a fair die, each outcome receives equal probability. If a value can be anywhere in a continuous interval, equal-length pieces of the interval receive equal probability. OpenStax’s statistics chapter uses a rectangle to illustrate the continuous case.

The support is the set of possible values. The same word uniform describes a finite equally likely list and a continuous interval, but the probability calculations are different.

Model Example Probability rule
Discrete uniform A fair die with six faces Count the favorable outcomes and divide by 6.
Continuous uniform A model for a moment selected uniformly from a 10-minute interval Divide the length of the desired portion by 10 minutes.
Continuous uniform density from two to ten with the portion from three to six shaded
For a uniform model from 2 to 10, the shaded interval from 3 to 6 occupies three of the eight units, so its probability is 3/83/8.

How do you find discrete uniform probabilities?

For nn equally likely outcomes, a particular outcome has probability 1/n1/n. If an event contains kk of them, its probability is k/nk/n. MIT’s random-variables notes distinguish probability mass for countable outcomes from probability density for a continuous variable.

If the possible values are consecutive integers from aa to bb, there are n=b−a+1n=b-a+1 values. The count includes both ends. The probability mass function is

P(X=x)=1b−a+1for x=a,a+1,…,b,P(X=x)=\frac{1}{b-a+1} \quad\text{for }x=a,a+1,\ldots,b,

and zero for other values. The mean is (a+b)/2(a+b)/2 and the variance is (n2−1)/12(n^2-1)/12. The variance formula applies to the consecutive-integer case. For an equally likely set such as {1,3,9}\{1,3,9\}, calculate the mean and squared deviations from those actual values. The variance guide explains that calculation.

What are the continuous uniform PDF, CDF, mean, and variance?

Write X~U(a,b)X\sim U(a,b) for a continuous uniform variable with a<ba<b. Its probability density function, or PDF, has constant height 1/(b−a)1/(b-a) between the endpoints. A rectangle with base b−ab-a and that height has total area 1.

f(x)={1b−a,a≤x≤b,0,otherwise.f(x)= \begin{cases} \dfrac{1}{b-a},&a\le x\le b,\\ 0,&\text{otherwise}. \end{cases}

The cumulative distribution function, or CDF, gives F(x)=P(X≤x)F(x)=P(X\le x). Between aa and bb, the rectangle under the density from aa to xx has width x−ax-a.

F(x)={0,x<a,x−ab−a,a≤x≤b,1,x>b.F(x)= \begin{cases} 0,&x<a,\\ \dfrac{x-a}{b-a},&a\le x\le b,\\ 1,&x>b. \end{cases}

NIST’s engineering statistics handbook lists the density, cumulative function, and percent point function. Its continuous uniform center is the midpoint. The variance is the average squared distance from that midpoint.

μ=a+b2,σ2=(b−a)212,σ=b−a12.\mu=\frac{a+b}{2}, \qquad \sigma^2=\frac{(b-a)^2}{12}, \qquad \sigma=\frac{b-a}{\sqrt{12}}.

For a brief derivation, center the interval at 0 with half-width h=(b−a)/2h=(b-a)/2. Its average squared distance is 12h∫−hht2dt=h2/3\frac{1}{2h}\int_{-h}^h t^2\,dt=h^2/3, which equals (b−a)2/12(b-a)^2/12.

How do you calculate an interval probability or a percentile?

For an interval [c,d][c,d] contained in [a,b][a,b], divide its length by the support width.

P(c≤X≤d)=d−cb−a.P(c\le X\le d)=\frac{d-c}{b-a}.

If an endpoint falls outside the support, intersect the requested interval with [a,b][a,b] first. If there is no overlap, the probability is zero. In a continuous model the endpoint itself contributes zero probability, so the answer does not change when you swap << for ≤\le.

For a percentile with probability qq between 0 and 1, solve F(x)=qF(x)=q to get x=a+q(b−a)x=a+q(b-a). This is also how you map a standard uniform value UU on [0,1][0,1] to any interval. The Naval Postgraduate School and TU Delft use continuous uniform examples to work with densities and interval widths.

Examples of Uniform Distribution Formulas

Example 1

A fair spinner has eight equally likely numbered regions from 1 through 8. Find the chance of a result of at least 6.

  1. The qualifying outcomes are 6, 7, and 8.
  2. They are three of the eight equally likely outcomes.
  3. The probability is 3/83/8. Counting 8−6=28-6=2 misses one endpoint for this discrete question.

Example 2

Let X~U(2,10)X\sim U(2,10). Find P(3≤X≤6)P(3\le X\le6) and P(X=6)P(X=6).

  1. The support width is 10−2=810-2=8.
  2. The first interval has length 6−3=36-3=3, so its probability is 3/83/8.
  3. The single point 6 has zero width, so P(X=6)=0P(X=6)=0.

Example 3

Let X~U(−2,4)X\sim U(-2,4). Find P(−4≤X≤1)P(-4\le X\le1).

  1. Values below −2-2 are outside the support.
  2. The overlapping interval is [−2,1][-2,1], of length 3.
  3. Divide by the total width 4−(−2)=64-(-2)=6. The probability is 1/21/2.

Example 4

Find the mean, variance, and standard deviation for U(0,20)U(0,20).

  1. The midpoint is (0+20)/2=10(0+20)/2=10.
  2. The variance is 202/12=100/320^2/12=100/3.
  3. The standard deviation is 10/3≈5.7710/\sqrt3\approx5.77.

Example 5

Find the 90th percentile for U(10,30)U(10,30).

  1. Set q=0.90q=0.90.
  2. Move across 90% of the interval width: 10+0.90(30−10)=2810+0.90(30-10)=28.
  3. Check that F(28)=(28−10)/20=0.90F(28)=(28-10)/20=0.90.

Example 6

Let X~U(0,12)X\sim U(0,12). Given that X>6X>6, find the probability that X>9X>9.

  1. The condition restricts the possible values to the six units from 6 to 12.
  2. Values above 9 cover the three units from 9 to 12.
  3. The conditional probability is 3/6=1/23/6=1/2.

What mistakes change the answer?

Mistake 1: Reporting density as a probability

For a uniform variable between 0 and 0.5, the density is 2. A density can exceed 1. The probability from 0 to 0.1 is 2·0.1=0.22\cdot0.1=0.2, because probability comes from the area under the density.

Mistake 2: Treating a list of integers as a continuous interval

There are six equally likely faces on a standard fair die, even though 6−1=56-1=5. In a discrete model count the endpoints. In a continuous model use the length between them.

Mistake 3: Assuming every bounded variable is uniform

A wait time bounded by 10 minutes can still cluster near zero or near ten. Uniformity requires a reason for equal-length intervals to be equally likely. For a clock with a strict 10-minute schedule, the assumption may fit an independent arrival with random phase. Arrivals timed to the schedule would give a different distribution.

Try It Yourself

  1. Find P(2<X<5)P(2<X<5) for a continuous uniform distribution on [0,10][0,10].
  2. Find the median of a continuous uniform distribution on [−3,7][-3,7].
  3. A fair random choice selects an integer from 3 through 9. What is the chance of selecting 6 or 7?

Answers and Reasoning

  1. The interval width is 3 and the total width is 10, so the probability is 3/103/10.
  2. The midpoint is (−3+7)/2=2(-3+7)/2=2. Each side has half the total probability.
  3. There are seven choices and two qualifying values, so the answer is 2/72/7.

Questions About the Uniform Distribution

Is a uniform distribution the same as a normal distribution?

A continuous uniform density is flat over a finite interval. A normal density is bell-shaped and extends indefinitely in both directions. The normal distribution lesson explains how its spread and probabilities differ.

What is a standard uniform distribution?

It is the continuous uniform distribution on [0,1][0,1]. Its density is 1 on the interval, and F(x)=xF(x)=x for 0≤x≤10\le x\le1.

What happens if a=ba=b?

The ordinary continuous uniform formula requires a<ba<b. Equal endpoints describe a constant value, with probability 1 concentrated at that single point.

Conclusion

  • Count outcomes for a discrete uniform model and measure widths for a continuous one.
  • Use the support to limit the interval before calculating its probability.
  • Use the midpoint and the width to calculate continuous mean and spread.

Read More

Research Behind This Article

  1. OpenStax, Statistics: The Uniform Distribution. OpenStax
  2. Massachusetts Institute of Technology, Random Variables in a Nutshell. MIT OpenCourseWare
  3. NIST/SEMATECH, Engineering Statistics Handbook: Uniform Distribution. NIST
  4. Naval Postgraduate School, Introduction to Statistics and Data Science: Continuous Random Variables. NPS
  5. TU Delft, Probability and Statistics Applications for Civil Engineers: Uniform Distribution. TU Delft