[Home](https://learningfolio.de5.net/) / [Math](https://learningfolio.de5.net/math/) / [Math glossary](https://learningfolio.de5.net/math/glossary/) / Uniform Distribution: Formulas and Worked Probability Examples

[Math glossary](https://learningfolio.de5.net/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.

Written by **Learningfolio Team**

We’re subject-matter experts in math, science, parent support, and education, with 100 years of combined experience. We believe in learning, experimenting, and growing, and we review one another’s work.

## On this page

* [TL;DR](https://learningfolio.de5.net/math/uniform-distribution-formula/#tldr)
* [Key Points](https://learningfolio.de5.net/math/uniform-distribution-formula/#key-points)
* [What is a uniform distribution?](https://learningfolio.de5.net/math/uniform-distribution-formula/#what-is-a-uniform-distribution)
* [How do you find discrete uniform probabilities?](https://learningfolio.de5.net/math/uniform-distribution-formula/#how-do-you-find-discrete-uniform-probabilities)
* [What are the continuous uniform PDF, CDF, mean, and variance?](https://learningfolio.de5.net/math/uniform-distribution-formula/#what-are-the-continuous-uniform-pdf-cdf-mean-and-variance)
* [How do you calculate an interval probability or a percentile?](https://learningfolio.de5.net/math/uniform-distribution-formula/#how-do-you-calculate-an-interval-probability-or-a-percentile)
* [Examples of Uniform Distribution Formulas](https://learningfolio.de5.net/math/uniform-distribution-formula/#examples-of-uniform-distribution-formulas)
* [What mistakes change the answer?](https://learningfolio.de5.net/math/uniform-distribution-formula/#what-mistakes-change-the-answer)
* [Try It Yourself](https://learningfolio.de5.net/math/uniform-distribution-formula/#try-it-yourself)
* [Questions About the Uniform Distribution](https://learningfolio.de5.net/math/uniform-distribution-formula/#questions-about-the-uniform-distribution)
* [Conclusion](https://learningfolio.de5.net/math/uniform-distribution-formula/#conclusion)
* [Read More](https://learningfolio.de5.net/math/uniform-distribution-formula/#read-more)
* [Research Behind This Article](https://learningfolio.de5.net/math/uniform-distribution-formula/#research-behind-this-article)

## TL;DR

**A uniform distribution gives equal probability to equal-sized choices.** In the discrete case, each outcome has probability $1/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]$ has constant density $1/(b-a)$ for $a<b$.
* The continuous uniform mean is $(a+b)/2$, and its variance is $(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](https://learningfolio.de5.net/assets/versioned/uniform-distribution-density-interval.0f63732a4f38.webp)


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/8$.

## How do you find discrete uniform probabilities?

For $n$ equally likely outcomes, a particular outcome has probability $1/n$. If an event contains $k$ of them, its probability is $k/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 $a$ to $b$, there are $n=b-a+1$ values. The count includes both ends. The probability mass function is

$$
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$ and the variance is $(n^2-1)/12$. The variance formula applies to the consecutive-integer case. For an equally likely set such as $\{1,3,9\}$, calculate the mean and squared deviations from those actual values. The [variance guide](https://learningfolio.de5.net/math/variance/) explains that calculation.

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

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

$$
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\le x)$. Between $a$ and $b$, the rectangle under the density from $a$ to $x$ has width $x-a$.

$$
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.

$$
\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)/2$. Its average squared distance is $\frac{1}{2h}\int_{-h}^h t^2\,dt=h^2/3$, which equals $(b-a)^2/12$.

## How do you calculate an interval probability or a percentile?

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

$$
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]$ 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 $q$ between 0 and 1, solve $F(x)=q$ to get $x=a+q(b-a)$. This is also how you map a standard uniform value $U$ on $[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/8$. Counting $8-6=2$ misses one endpoint for this discrete question.

### Example 2

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

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

### Example 3

Let $X\sim U(-2,4)$. Find $P(-4\le X\le1)$.

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

### Example 4

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

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

### Example 5

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

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

### Example 6

Let $X\sim U(0,12)$. Given that $X>6$, find the probability that $X>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/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\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=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)$ for a continuous uniform distribution on $[0,10]$.
2. Find the median of a continuous uniform distribution on $[-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/10$.
2. The midpoint is $(-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/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](https://learningfolio.de5.net/math/normal-distribution/) explains how its spread and probabilities differ.

### What is a standard uniform distribution?

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

### What happens if $a=b$?

The ordinary continuous uniform formula requires $a<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

* [How to count outcomes in a standard deck](https://learningfolio.de5.net/math/probability-and-playing-cards/)
* [Why sample means can become approximately normal](https://learningfolio.de5.net/math/central-limit-theorem/)

## Research Behind This Article

1. OpenStax, *Statistics: The Uniform Distribution*. [OpenStax](https://openstax.org/books/statistics/pages/5-2-the-uniform-distribution)
2. Massachusetts Institute of Technology, *Random Variables in a Nutshell*. [MIT OpenCourseWare](https://ocw.mit.edu/courses/2-086-numerical-computation-for-mechanical-engineers-fall-2014/84a1a919d238bbaea0bbae1ce3b8be3c_MIT2_086F14_Random_Var.pdf)
3. NIST/SEMATECH, *Engineering Statistics Handbook: Uniform Distribution*. [NIST](https://www.itl.nist.gov/div898/handbook/eda/section3/eda3662.htm)
4. Naval Postgraduate School, *Introduction to Statistics and Data Science: Continuous Random Variables*. [NPS](https://faculty.nps.edu/rbassett/_book/continuous-random-variables.html)
5. TU Delft, *Probability and Statistics Applications for Civil Engineers: Uniform Distribution*. [TU Delft](https://tudelft-citg.github.io/learn-probability/section_03/3_1_Uniform_dist.html)
