Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Discrete Uniform Distribution






Discrete Uniform Distribution: Equal-Chance Selection


The probabilistic experiment behind the discrete uniform distribution is one where a single outcome is selected from a finite set of possibilities, and every outcome is equally likely. There is no notion of success or failure, repetition, or accumulation — only a fair selection from a fixed range. Rolling a fair die or randomly choosing an integer from a known interval are typical examples. The defining feature of this experiment is the absence of bias: no outcome is favored over another.

Key Terms

Discrete Uniform Distribution— equal probability across a finite set of values
Equally Likely Events— the underlying assumption of the discrete uniform
Expected Value— E[X]=(a+b)/2E[X] = (a+b)/2
Variance— Var⁡(X)=(n2−1)/12\operatorname{Var}(X) = (n^2-1)/12

See All Probability Definitions →


The Probabilistic Experiment Behind Discrete Uniform distribution

Five experiments, each with a short list of whole-number results. In which of them is every result equally likely?
All five produce a value from a known finite range, and several involve fair dice or coins, so it is tempting to say "all of them".
experimentpossible values
roll one fair die1 to 6
roll two fair dice, add them2 to 12
roll a die loaded toward 61 to 6
draw a card from a shuffled deck, read its rank1 (ace) to 13 (king)
flip three fair coins, count heads0 to 3
Only two spread their probability evenly: the single fair die and the card rank.
experimentprobabilitiesall equal?
one fair die1/6 eachyes
sum of two dice1/36 for 2, up to 6/36 for 7no
loaded die6 more likely than the restno
card rank4/52 = 1/13 eachyes
heads in three flips1/8, 3/8, 3/8, 1/8no
The loaded die fails on symmetry; the sum and the head count fail because they combine several picks.
The loaded die is one pick, but its mechanism prefers one face. The sum of two dice and the number of heads are built from fair parts, yet some totals can be made in more ways than others — a total of 7 in six ways, a total of 2 in one. The card rank passes even though the deck has 52 cards, because every rank appears exactly four times.
The rule: a single pick from a finite set, by a mechanism that treats every value alike.
Think of a raffle drum full of identical tickets: nothing about a ticket makes it easier or harder to draw.
The discrete uniform distribution represents situations where a random experiment produces outcomes from a finite set, and every outcome is equally likely. There is no preference, weighting, or bias toward any value in the set. The defining feature is not randomness alone, but symmetry: the mechanism that generates outcomes treats all possibilities identically.
The definition
The discrete uniform distribution on the integers a,a+1,…,ba, a + 1, \dots, b gives each of the n=b−a+1n = b - a + 1 values the same probability: P(X=k)=1nP(X = k) = \dfrac{1}{n}.
So one roll of a fair die is discrete uniform on 11 to 66, with P(X=k)=16P(X = k) = \frac{1}{6}.
It is the simplest discrete distribution: fixed entirely by its range.
This distribution is appropriate when the experiment consists of one selection from a known finite collection and there is no additional structure such as repeated trials, success–failure outcomes, or dependence between selections. Once the range of possible values is fixed, the distribution is fully determined. There are no hidden dynamics — probability is spread evenly across the entire support.

Example
Rolling a fair six-sided die once. The possible outcomes are {1,2,3,4,5,6}\{1,2,3,4,5,6\}, and each value has the same probability. No outcome is favored over another by the mechanism of the experiment.
The rejected experiments are not far away: they are built from uniform pieces.
The 36 ordered pairs of two fair dice are themselves discrete uniform; only adding them up makes the totals uneven.
Due to this simplicity, the discrete uniform distribution often serves as a baseline model. More complex discrete distributions can frequently be understood as deviations from uniformity caused by repetition, conditioning, or structural constraints.
Did you know: No loading makes the sum flat
However two dice are weighted, their total is never uniform on 22 to 1212. With face probabilities pip_i and qiq_i, a flat total needs p1q1=p6q6=111p_1 q_1 = p_6 q_6 = \frac{1}{11}, and then P(7)≥p1q6+p6q1≥2111⋅111=211P(7) \geq p_1 q_6 + p_6 q_1 \geq 2\sqrt{\frac{1}{11} \cdot \frac{1}{11}} = \frac{2}{11}.
Two dice show the effect of repetition. Each die on its own is uniform on 11 to 66, but their total runs from 22 to 1212 and crowds toward the middle, because a total of 77 can be made in six ways and a total of 22 in only one. A natural question is whether some other weighting of the faces could bring the totals back to equal footing.
One fair die: six equal bars of 1/6. The sum of two dice: a triangle from 2 to 12, peaked at 7xy123456789101112blue: one die, 1/6 eachamber: sum of two dice7 has 6 of 36 waysOne die is uniform; adding two dice is not
Uniform as the baseline

Blue bars: one roll of a fair die, six values of probability 1/6 each, the discrete uniform on 1 to 6. Amber bars: the sum of two dice. Every one of the 36 ordered pairs is still equally likely, but the sums are not: 7 can be made in 6 ways and 2 or 12 in only one. Repeating the experiment and adding turns the flat profile into a triangle.

Flat over single picks, uneven over their sums: one source of the other discrete shapes.
A discrete uniform is pure symmetry: once the range is fixed, nothing else is left to choose.
The rest of the page covers the notation, the parameters, the PMF and CDF, the mean, variance, mode and median, and further properties.

Discrete Uniform Notation

Notation

Discrete Uniform Notation

This is the one distribution whose name is genuinely ambiguous: U(a,b)U(a, b) names this family and its continuous namesake equally, and the two behave differently. The marks below are the disambiguators — the letters that resolve the name, the counted denominator, and the support that gives the game away. All catalogued among the probability symbols.
The declaration tilde and capital/lowercase split come from random variable notation and distribution notation; set braces from set notation; E[X]E[X] and Var⁡(X)\operatorname{Var}(X) from expected value and variance notation.
X∼DU⁡(a,b)X \sim \operatorname{DU}(a, b)
discrete uniform on the integers from a to b
The unambiguous spellings put the word in the name: DU⁡\operatorname{DU}, DiscreteUniform⁡\operatorname{DiscreteUniform}, sometimes Unif⁡\operatorname{Unif} qualified in prose. Bare U(a,b)U(a, b) is the problem — it names this family and the continuous uniform with equal authority, and nothing inside the parentheses distinguishes them.
CasesTwo tells resolve it without asking the author: integer-looking bounds and a pmf mean discrete, real bounds with a density mean continuous; and the standard instance is written DU⁡(1,n)\operatorname{DU}(1, n) — the fair die, the random draw from a numbered list.
Do not confuseIts continuous namesake, in both directions. The same U(3,7)U(3, 7) can mean five equally likely integers or an interval of infinitely many points — the first assigns each outcome probability 1/51/5, the second assigns every single point probability zero.
P(X=k)=1b−a+1P(X{=}k) = \dfrac{1}{b - a + 1}
one over the number of values — bounds included
The denominator counts outcomes rather than measuring width, and the +1+1 is why: the integers from aa to bb inclusive number b−a+1b - a + 1, not b−ab - a. That single term is the whole notational difference from the continuous uniform's 1/(b−a)1/(b-a).
CasesOn the standard DU⁡(1,n)\operatorname{DU}(1, n) the count collapses to the familiar 1/n1/n — the form most texts introduce first, and the reason the +1+1 often goes unnoticed until the lower bound stops being one.
Do not confuseThe interval width. Writing 1/(b−a)1/(b-a) here is the fencepost error in probabilistic dress: on DU⁡(1,6)\operatorname{DU}(1, 6) it hands each face 1/51/5, and the six probabilities sum to 1.21.2.
k=a, a+1, …, bk = a,\ a{+}1,\ \ldots,\ b
the support is a list of integers, endpoints included
A stepped list, not an interval: the support is {a,a+1,…,b}\{a, a+1, \ldots, b\} — spelled with set braces where the continuous family writes [a,b][a, b]. Braces against brackets is the fastest discrete/continuous tell on the page.
CasesIt joins the family's support-style census as its fifth member — beside the binomial's closed list, the Poisson's open ellipsis, the hypergeometric's clamps and the negative binomial's shifted list: here, a finite run with both ends named.
Do not confuseThe real interval [a,b][a, b]. The bracket form admits every real number between the bounds; this family admits only the integers among them, and the notation is the only place that distinction is recorded.
DownloadPNG2×PDF
Notation · Cheat sheet
Distribution Notation at a Glance
The marks from the notation cards across the distribution pages: how each is read and what it means. Every group links to the full card on its page.
Distributions
(Ω,F,P)(\Omega, \mathcal{F}, \mathbb{P})
a probability space
Outcomes, events, and the probability measure.
PX(A)\mathbb{P}_X(A)
the distribution of X
Equals P(X∈A)\mathbb{P}(X \in A).
X=dYX \overset{d}{=} Y
equal in distribution
Same law, not necessarily the same values.
Binomial
X∼Bin⁡(n,p)X \sim \operatorname{Bin}(n, p)
binomial, n trials, p
The number of successes in nn independent trials.
q=1−pq = 1 - p
q, the failure probability
An abbreviation, not a new parameter.
Geometric
Geom⁡(p)\operatorname{Geom}(p)
geometric with p
Two conventions: count trials, or count failures.
qk−1pq^{k-1}p vs qkpq^k p
the two pmfs
The exponent shows which convention is in use.
Negative binomial
NB⁡(r,p)\operatorname{NB}(r, p)
negative binomial
Trials until the rr-th success.
k=r,r+1,…k = r, r{+}1, \ldots
the support starts at r
Fewer trials cannot hold rr successes.
Hypergeometric
Hyp⁡(N,K,n)\operatorname{Hyp}(N, K, n)
hypergeometric
Population NN with KK successes; nn draws without replacement.
(Kk)(N−Kn−k)(Nn)\frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}
the pmf
Successes chosen, failures chosen, over all samples.
Poisson
Pois⁡(λ)\operatorname{Pois}(\lambda)
Poisson with rate lambda
Counts of events in a window.
λ\lambda
lambda
The expected count per window; it depends on the window size.
Discrete uniformThis page
DU⁡(a,b)\operatorname{DU}(a, b)
discrete uniform
Each integer from aa to bb equally likely.
1b−a+1\frac{1}{b - a + 1}
one over the count
The +1+1 counts both endpoints.
Continuous uniform
X∼U(a,b)X \sim U(a, b)
uniform from a to b
The slots are the endpoints, not a centre and a spread.
1b−a\frac{1}{b - a}
one over the width
A flat density; no +1+1 here.
Exponential
Exp⁡(λ)\operatorname{Exp}(\lambda)
exponential with rate lambda
Some books put the scale β=1λ\beta = \frac{1}{\lambda} in the slot.
P(X>x)=e−λxP(X > x) = e^{-\lambda x}
the survival tail
The chance of waiting longer than xx.
Normal
N(μ,σ2)N(\mu, \sigma^2)
normal, mean mu
Second slot: usually the variance; some texts use σ\sigma.
Z∼N(0,1)Z \sim N(0, 1)
capital Z, standard normal
A score z=x−μσz = \frac{x - \mu}{\sigma} counts standard deviations.
φ(z),  Φ(z)\varphi(z), \; \Phi(z)
phi; capital Phi
The standard normal density and its CDF.
Same marks, different job
N(μ,σ2)N(\mu, \sigma^2)Check whether the second slot is the variance or the standard deviation.
Exp⁡(λ)\operatorname{Exp}(\lambda)Rate or scale: the two readings give means 1λ\frac{1}{\lambda} and λ\lambda.
U(a,b)U(a, b) vs DU⁡(a,b)\operatorname{DU}(a, b)Width b−ab - a against a count of b−a+1b - a + 1 values.
Φ\Phi vs φ\varphiCapital is the CDF, lowercase the density.
Distribution Notation at a Glance·/probability/distributionsLearn Math Class

Parameters


aa : the smallest integer in the range

bb : the largest integer in the range

The uniform discrete distribution assigns equal probability to each integer between aa and bb, inclusive.

The values must be distinct and finite in number; in the usual integer case, as here, they are also equally spaced.

The parameters define the range — once aa and bb are set, every integer in that closed interval has probability 1b−a+1\frac{1}{b - a + 1}.

This distribution is used when there's no reason to favor any outcome over another — every value is equally likely by design.

Probability Mass Function (PMF) and Support (Range)


The probability mass function (PMF) of a discrete uniform distribution is given by:

Discrete Uniform PMF
P(X=x)=1b−a+1=1n,x∈{x1,x2,…,xn}P(X = x) = \frac{1}{b - a + 1} = \frac{1}{n}, \quad x \in \{x_1, x_2, \dots, x_n\}
Learn more about this formula: Discrete Uniform PMF →


Where :
aa = lower bound (integer)
bb = upper bound (integer)
n=b−a+1n=b−a+1 is total number of possible values

Intuition Behind the Formula


Uniformity: The term "uniform" implies that each outcome is equally likely. That is, no single value of the random variable is preferred over another. This is the key feature of a uniform distribution.

Support (Range of the Random Variable):
* The random variable XX can take on n=b−a+1n = b - a + 1 distinct values: x1,x2,…,xnx_1, x_2, \ldots, x_n.
* These values could be consecutive integers (like 1,2,3,…,n1, 2, 3, \ldots, n) or, more generally, any set of nn distinct values (the formulas on this page use the consecutive integers a,a+1,…,ba, a+1, \ldots, b).
* The range or support is thus a finite, countable set.

Logic Behind the Formula:

The total probability must sum to 1:

∑i=1nP(X=xi)=1\sum_{i=1}^n P(X = x_i) = 1

Since all probabilities are equal:

n⋅1n=(b−a+1)⋅1b−a+1=1n \cdot \frac{1}{n} = (b - a + 1) \cdot \frac{1}{b - a + 1} = 1

This makes the individual probability of each outcome 1n=1b−a+1\frac{1}{n} = \frac{1}{b - a + 1}.

Pitfall: Forgetting to count both ends
Counting the integers from 1010 to 2020 as 20−10=1020 - 10 = 10 gives each value 110\frac{1}{10}, and the 1111 probabilities add up to 1.11.1. Both bounds are values: n=20−10+1=11n = 20 - 10 + 1 = 11, so P(X=x)=111P(X = x) = \frac{1}{11}.

In practice the formula is used by counting. The bounds aa and bb are read off the problem, the values from aa to bb are counted, and that count becomes the denominator shared by every outcome. On a standard die the count is plain to see; on a range such as the integers from 1010 to 2020, it has to be worked out from the bounds.


Discrete Uniform Distribution

Equal probability for finite outcomes

Explanation

A discrete uniform distribution assigns equal probability to each value in a finite range. The probability mass function is P(X=k)=1b−a+1P(X = k) = \frac{1}{b - a + 1} for a≤k≤ba \leq k \leq b. The expected value is E[X]=a+b2E[X] = \frac{a + b}{2}, and the variance is Var(X)=n2−112\text{Var}(X) = \frac{n^2 - 1}{12}, where n=b−a+1n = b - a + 1. Common examples include rolling a fair die, selecting a random card from a deck, or generating a random number from a finite range.

0.0000.0400.0800.1200.1600.200123456Value (k)Probability P(X = k)
Discrete uniform PMF, a = 1 to b = 6

Six bars of equal height 1/6 stand at the integers 1 to 6: every value in the range is equally likely and nothing lies outside it. The height is always 1 over the number of values, so widening the range lowers every bar. Change a and b and watch the bars redistribute on the PMF visualizer.

The cumulative form is a regular staircase.
Every discrete uniform probability is one over a count, so the whole calculation rests on counting the values correctly.

Cumulative Distribution Function (CDF)


The cumulative distribution function (CDF) of a discrete uniform distribution is given by:

Discrete Uniform CDF
FX(x)=P(X≤x)={0,x<a⌊x⌋−a+1b−a+1,a≤x≤b1,x>bF_X(x) = P(X \leq x) = \begin{cases} 0, & x < a \\ \frac{\lfloor x \rfloor - a + 1}{b - a + 1}, & a \leq x \leq b \\ 1, & x > b \end{cases}
Learn more about this formula: Discrete Uniform CDF →


Where:
aa = lower bound (integer)
bb = upper bound (integer)
⌊x⌋\lfloor x \rfloor = floor function (largest integer less than or equal to xx)

Intuition Behind the Formula


Definition: The CDF gives the probability that the random variable XX takes on a value less than or equal to xx.

Three Regions:

1. Before the range (x<ax < a): No outcomes are possible below aa, so FX(x)=0F_X(x) = 0.

2. Within the range (a≤x≤ba \leq x \leq b): The CDF counts how many integer values from aa to ⌊x⌋\lfloor x \rfloor are included, divided by the total number of outcomes (b−a+1)(b - a + 1).
* Number of outcomes up to ⌊x⌋\lfloor x \rfloor: ⌊x⌋−a+1\lfloor x \rfloor - a + 1
* Total outcomes: b−a+1b - a + 1
* Therefore: FX(x)=⌊x⌋−a+1b−a+1F_X(x) = \frac{\lfloor x \rfloor - a + 1}{b - a + 1}

3. After the range (x>bx > b): All outcomes have occurred, so FX(x)=1F_X(x) = 1.

Step Function Behavior: Since XX only takes integer values, the CDF remains constant between integers and jumps by 1b−a+1\frac{1}{b - a + 1} at each integer point.

Pitfall: Treating at least as more than
For a fair die, writing P(X≥3)=1−FX(3)=1−36=12P(X \geq 3) = 1 - F_X(3) = 1 - \frac{3}{6} = \frac{1}{2} drops the face 33 itself. At least 33 means 3,4,5,63, 4, 5, 6, so P(X≥3)=1−FX(2)=1−26=23P(X \geq 3) = 1 - F_X(2) = 1 - \frac{2}{6} = \frac{2}{3}.

Questions about a range of outcomes are answered from this staircase. A roll below 44, a draw of at least 1515, a number of at most 88: each picks out a block of consecutive values, and its probability is read from the CDF, directly or through the complement. Because every jump has the same height, each value that lands inside or outside the block changes the answer by exactly 1b−a+1\frac{1}{b - a + 1}.

Discrete Uniform Distribution CDF

CDF rises uniformly in equal steps

CDF Explanation

The cumulative distribution function (CDF) for the discrete uniform distribution is F(k)=⌊k⌋−a+1b−a+1F(k) = \frac{\lfloor k \rfloor - a + 1}{b - a + 1} for a≤k≤ba \leq k \leq b. The CDF increases in equal steps of 1n\frac{1}{n} where n=b−a+1n = b - a + 1 is the number of possible values. Each step represents one additional outcome being included in the cumulative probability. The CDF reaches 1.0 at the maximum value bb and remains at 1.0 for all larger values.
0.00.20.40.60.81.0123456Value (k)Cumulative Probability F(k)
Discrete uniform CDF, a = 1 to b = 6

Because every bar has the same height the staircase climbs in equal steps of 1/6, reaching 1 at b. F(k) is the number of values up to k over the total number of values, a straight count. Compare the even steps with the uneven staircases of other families on the discrete CDF explorer.

The mean is the midpoint of the range.

Expected Value (Mean)


As explained in the general case for calculating expected value, the expected value of a discrete random variable is computed as a weighted sum where each possible value is multiplied by its probability:

Expected Value (Discrete)
E[X]=∑xx⋅P(X=x)E[X] = \sum_{x} x \cdot P(X = x)
Learn more about this formula: Expected Value (Discrete) →


For the discrete uniform distribution, we apply this general formula to the specific probability mass function of this distribution.

Formula


Discrete Uniform Mean
E[X]=a+b2E[X] = \frac{a + b}{2}
Learn more about this formula: Discrete Uniform Mean →


Where:
aa = minimum value (lower bound)
bb = maximum value (upper bound)

Derivation and Intuition


Starting from the general definition and substituting the PMF P(X=x)=1b−a+1P(X = x) = \frac{1}{b - a + 1} for each x∈{a,a+1,…,b}x \in \{a, a+1, \ldots, b\}:

Expected Value (Mean)
E[X]=∑x=abx⋅1b−a+1=1b−a+1∑x=abxE[X] = \sum_{x=a}^{b} x \cdot \frac{1}{b - a + 1} = \frac{1}{b - a + 1} \sum_{x=a}^{b} x

The sum of integers from aa to bb is:

Expected Value (Mean)
∑x=abx=(b−a+1)(a+b)2\sum_{x=a}^{b} x = \frac{(b - a + 1)(a + b)}{2}

Substituting back:

Expected Value (Mean)
E[X]=1b−a+1⋅(b−a+1)(a+b)2=a+b2E[X] = \frac{1}{b - a + 1} \cdot \frac{(b - a + 1)(a + b)}{2} = \frac{a + b}{2}
The derivation of the mean above as a chain, each line with its reason.
DownloadPNG2×PDF
ShowE[X]=a+b2E[X] = \frac{a + b}{2}
1
E[X]=∑x=abx⋅1b−a+1E[X] = \sum_{x=a}^{b} x \cdot \frac{1}{b - a + 1}
PMFThe general definition with P(X=x)=1b−a+1P(X = x) = \frac{1}{b - a + 1}
2
=1b−a+1∑x=abx= \frac{1}{b - a + 1} \sum_{x=a}^{b} x
factorTake out the constant
3
∑x=abx=(b−a+1)(a+b)2\sum_{x=a}^{b} x = \frac{(b - a + 1)(a + b)}{2}
key stepThe sum of the integers from aa to bb
4
E[X]=1b−a+1⋅(b−a+1)(a+b)2E[X] = \frac{1}{b - a + 1} \cdot \frac{(b - a + 1)(a + b)}{2}
substituteSubstituting back
5
=a+b2= \frac{a + b}{2}
cancelThe factor b−a+1b - a + 1 cancels
E[X]=a+b2E[X] = \frac{a + b}{2}
Deriving the discrete uniform meanLearn Math Class
The gold step, the sum of the integers from aa to bb, brings in the factor b−a+1b - a + 1 that cancels the denominator of the PMF.
The result E[X]=a+b2E[X] = \frac{a + b}{2} captures the symmetry of the uniform distribution: the expected value is simply the midpoint between the minimum and maximum values. Since all outcomes are equally likely, the average naturally falls at the center of the range.

Example


Consider rolling a fair six-sided die, where a=1a = 1 and b=6b = 6:

Expected Value (Mean)
E[X]=1+62=3.5E[X] = \frac{1 + 6}{2} = 3.5

The expected value is 3.5, which is the arithmetic mean of all possible outcomes {1,2,3,4,5,6}\{1, 2, 3, 4, 5, 6\}. Note that the expected value need not be a possible outcome of the random variable.

Did you know: Counting tanks by serial number
In World War II, Allied statisticians read captured German serial numbers as draws from 11 to NN and estimated NN from the largest numbers seen. For tanks built in August 1942 they got 327, intelligence reports said 1,550, and German records later showed 342.

The formula also works in reverse. When the values are numbered 11 to NN and NN itself is unknown, every observed value is a draw from that range, and the largest values seen, together with how many were seen, show how far the range must reach. Serial numbers stamped on manufactured items form exactly such a range.

To compute the expected value of a discrete uniform distribution for your own parameters, step by step, use the discrete uniform expected value calculator.

Variance and Standard Deviation


The variance of a discrete random variable measures how spread out the values are around the expected value. It is computed as:

Variance and Standard Deviation
Var(X)=E[(X−μ)2]=∑x(x−μ)2P(X=x)\mathrm{Var}(X) = \mathbb{E}[(X - \mu)^2] = \sum_{x} (x - \mu)^2 P(X = x)

Or using the shortcut formula:

Variance and Standard Deviation
Var(X)=E[X2]−μ2\mathrm{Var}(X) = \mathbb{E}[X^2] - \mu^2

For the discrete uniform distribution, we apply this formula to derive the variance.

Formula


Discrete Uniform Variance
Var(X)=(b−a+1)2−112\mathrm{Var}(X) = \frac{(b - a + 1)^2 - 1}{12}
Learn more about this formula: Discrete Uniform Variance →


Where:
aa = minimum value (lower bound)
bb = maximum value (upper bound)

Derivation and Intuition


Starting with the shortcut formula, we need to calculate E[X2]\mathbb{E}[X^2].

We know from the expected value section that μ=a+b2\mu = \frac{a + b}{2}.

For E[X2]\mathbb{E}[X^2], using the PMF P(X=x)=1b−a+1P(X = x) = \frac{1}{b - a + 1}:

Variance and Standard Deviation
E[X2]=∑x=abx2⋅1b−a+1=1b−a+1∑x=abx2\mathbb{E}[X^2] = \sum_{x=a}^{b} x^2 \cdot \frac{1}{b - a + 1} = \frac{1}{b - a + 1} \sum_{x=a}^{b} x^2

Using the formula for sum of squares: ∑x=abx2=(b−a+1)(2b2+2ab+2a2−a+b)6\sum_{x=a}^{b} x^2 = \frac{(b - a + 1)(2b^2 + 2ab + 2a^2 - a + b)}{6}

After algebraic manipulation:

Variance and Standard Deviation
Var(X)=E[X2]−μ2=(b−a+1)2−112\mathrm{Var}(X) = \mathbb{E}[X^2] - \mu^2 = \frac{(b - a + 1)^2 - 1}{12}
The variance computation above as a chain, from E[X2]\mathbb{E}[X^2] to the shortcut formula.
DownloadPNG2×PDF
ShowVar(X)=(b−a+1)2−112\mathrm{Var}(X) = \frac{(b - a + 1)^2 - 1}{12}
1
E[X2]=∑x=abx2⋅1b−a+1\mathbb{E}[X^2] = \sum_{x=a}^{b} x^2 \cdot \frac{1}{b - a + 1}
PMFUsing the PMF P(X=x)=1b−a+1P(X = x) = \frac{1}{b - a + 1}
2
=1b−a+1∑x=abx2= \frac{1}{b - a + 1} \sum_{x=a}^{b} x^2
factorTake out the constant
3
∑x=abx2=(b−a+1)(2b2+2ab+2a2−a+b)6\sum_{x=a}^{b} x^2 = \frac{(b - a + 1)(2b^2 + 2ab + 2a^2 - a + b)}{6}
key stepThe formula for the sum of squares
4
Var(X)=E[X2]−μ2\mathrm{Var}(X) = \mathbb{E}[X^2] - \mu^2
shortcutThe shortcut formula, with μ=a+b2\mu = \frac{a + b}{2} from the expected value section
5
=(b−a+1)2−112= \frac{(b - a + 1)^2 - 1}{12}
simplifyAfter algebraic manipulation
Var(X)=(b−a+1)2−112\mathrm{Var}(X) = \frac{(b - a + 1)^2 - 1}{12}
Deriving the discrete uniform varianceLearn Math Class
The sum of squares is the gold step; after the simplification only the number of values b−a+1b - a + 1 is left in the result.
The result shows that variance depends on the range width (b−a+1)(b - a + 1) squared. A wider range of equally likely values produces higher variance. The formula is symmetric and increases quadratically with the spread between aa and bb.

Standard Deviation


Variance and Standard Deviation
σ=Var(X)=(b−a+1)2−112\sigma = \sqrt{\mathrm{Var}(X)} = \sqrt{\frac{(b - a + 1)^2 - 1}{12}}

Example


For a fair six-sided die where a=1a = 1 and b=6b = 6:

Variance and Standard Deviation
Var(X)=(6−1+1)2−112=36−112=3512≈2.917\mathrm{Var}(X) = \frac{(6 - 1 + 1)^2 - 1}{12} = \frac{36 - 1}{12} = \frac{35}{12} \approx 2.917

Variance and Standard Deviation
σ=3512≈1.708\sigma = \sqrt{\frac{35}{12}} \approx 1.708

Pitfall: Using the continuous variance formula
Borrowing (b−a)212\frac{(b - a)^2}{12} from the continuous uniform gives the die (6−1)212=2512≈2.083\frac{(6 - 1)^2}{12} = \frac{25}{12} \approx 2.083. The discrete formula counts the values: 62−112=3512≈2.917\frac{6^2 - 1}{12} = \frac{35}{12} \approx 2.917.

The variance of approximately 2.917 indicates moderate spread around the mean of 3.5, with outcomes ranging from 1 to 6.
Two discrete uniforms centred at 5: three values with variance 2/3, nine values with variance 20/3xy12345678910amber: n = 3, Var ≈ 0.67blue: n = 9, Var ≈ 6.67both: mean 53 times as many values, 10 times the variance
Variance against the number of values

Two discrete uniforms, both centred at 5. Amber: the values 4, 5, 6, each with probability 1/3, variance (3² − 1)/12 ≈ 0.67. Blue: the values 1 to 9, each with probability 1/9, variance (9² − 1)/12 ≈ 6.67. Three times as many values give ten times the variance, because the formula grows with n².

Moving the range left or right changes the mean but never the variance: only n = b − a + 1 counts.

Mode and Median

Mode


The mode is the value of kk with the highest probability—the peak of the PMF.

For the discrete uniform distribution, all values have equal probability, so:

RULE
Every value in the range {a,a+1,a+2,…,b}\{a, a+1, a+2, \ldots, b\} is a mode

The distribution is multimodal with b−a+1b - a + 1 modes.

Intuition: Since the discrete uniform distribution assigns equal probability 1b−a+1\frac{1}{b-a+1} to each value, no single outcome is more likely than any other. This reflects complete uncertainty within the specified range—all outcomes are equally probable.

Example
For a=1a = 1, b=6b = 6 (rolling a fair die):
Modes = 1, 2, 3, 4, 5, 6 (all equally likely with probability 16\frac{1}{6})

Example
For a=0a = 0, b=4b = 4:
Modes = 0, 1, 2, 3, 4 (all equally likely with probability 15\frac{1}{5})

Median


The median is the value mm such that P(X≤m)≥0.5P(X \leq m) \geq 0.5 and P(X≥m)≥0.5P(X \geq m) \geq 0.5.

For the discrete uniform distribution:

If b−a+1b - a + 1 is odd:
Median = a+b2\frac{a + b}{2} (the middle value)

If b−a+1b - a + 1 is even:
Any value between a+b−12\frac{a + b - 1}{2} and a+b+12\frac{a + b + 1}{2} can be considered the median

Properties of the median:
• The median equals the expected value a+b2\frac{a + b}{2} when the range has an odd number of values
• For symmetric distributions, median = mean; when there is a single peak, the mode equals them too
• The median represents the center of the distribution

Example
For a=1a = 1, b=6b = 6:
Mean = 1+62=3.5\frac{1 + 6}{2} = 3.5
Median = 3.5 (between 3 and 4)

Example
For a=1a = 1, b=5b = 5:
Mean = 1+52=3\frac{1 + 5}{2} = 3
Median = 3 (the exact middle value)

Unlike continuous distributions where finding the median requires integration, for discrete distributions, the median is found by identifying the middle value(s) when outcomes are equally spaced and equally probable.

Applications and Examples


### Practical Example
Suppose you roll a fair six-sided die. The possible outcomes are {1,2,3,4,5,6}\{1, 2, 3, 4, 5, 6\}, and the probability of each face is:

P(X=x)=16=16−1+1,x=1,2,3,4,5,6P(X = x) = \frac{1}{6} = \frac{1}{6 - 1 + 1}, \quad x = 1, 2, 3, 4, 5, 6

Each face has an equal and independent chance of appearing.

Interactive Calculator


This interactive calculator computes probabilities for the discrete uniform distribution, where every value in a range has equal probability of occurring. Enter your minimum value (aa) and maximum value (bb) to model scenarios like fair dice rolls, random number selection, or lottery draws. The calculator shows you the equal probability for each value and lets you compute cumulative probabilities for any range within your specified bounds.

1. Select probability type: 'All values' for full distribution, or choose a specific query
2. Enter a (minimum value) - lowest possible value (integer)
3. Enter b (maximum value) - highest possible value (integer, must be greater than a)
4. For specific queries, enter x (target value) - the specific value you want to query
5. Click Calculate to see probabilities and distribution

Discrete Uniform Distribution Calculator

Enter the minimum (a) and maximum (b) values

Minimum value (integer)

Maximum value (integer)

,

Related Distributions


The discrete uniform distribution has no trials and no rate, only a list of equally likely values, so its relatives are few. They come from making the list finer, cutting it down to two values, dropping the equal chances, or adding several draws together.

Continuous uniform: a finer and finer grid


Place nn equally likely values at 1n,2n,…,1\frac{1}{n}, \frac{2}{n}, \ldots, 1. The chance of landing at or below a point xx between 00 and 11 is the number of grid values up to xx, divided by nn:

Related Distributions
P(Xn≤x)=⌊nx⌋n→xas n→∞P(X_n \leq x) = \frac{\lfloor nx \rfloor}{n} \to x \quad \text{as } n \to \infty

and F(x)=xF(x) = x is the CDF of the continuous uniform distribution on (0,1)(0, 1). The variance follows along: n2−112n2\frac{n^2 - 1}{12n^2} approaches 112\frac{1}{12}. The link also runs back, and computers use it to roll dice: if UU is a continuous uniform value on (0,1)(0, 1), then ⌊6U⌋+1\lfloor 6U \rfloor + 1 is uniform on 11 to 66.

Bernoulli: two values


On the two values 00 and 11 the discrete uniform is the Bernoulli distribution with p=12p = \frac{1}{2}, a fair coin. The formulas agree: the mean 0+12=12\frac{0 + 1}{2} = \frac{1}{2} is pp, and the variance 22−112=14\frac{2^2 - 1}{12} = \frac{1}{4} is p(1−p)p(1 - p).

Categorical: unequal chances


A categorical distribution gives each of nn values its own probability p1,p2,…,pnp_1, p_2, \ldots, p_n, with the probabilities adding up to 11. The discrete uniform is the case where every pip_i equals 1n\frac{1}{n}. A loaded die is categorical but not uniform: the same six values, with different chances.

Sums of draws: a triangle, then a bell


A sum of uniform draws is not uniform. The total SS of two dice runs from 22 to 1212 with probabilities that rise to a peak at 77 and fall back:

Related Distributions
P(S=s)=6−∣s−7∣36,s=2,3,…,12P(S = s) = \frac{6 - |s - 7|}{36}, \quad s = 2, 3, \ldots, 12

As more dice are added the triangle rounds into a bell, and the total approaches the normal distribution by the central limit theorem. The total of nn dice has mean 3.5n3.5n and variance 35n12\frac{35n}{12}.

Of these, the continuous uniform link is the one met most often: the two distributions share a name and a midpoint mean, and differ in whether values are counted or measured.

Discrete Uniform at a Glance

This summary gathers the discrete uniform distribution on one card of eight rows. Each row names one part of the distribution with a line on what it gives and a link to the section that explains it, then states the formula or fact and adds a note or a worked number.

The first rows fix the setup: the smallest and the largest value, how many values lie between them, and the whole numbers that make up the support. Then come the equal probability of every value, the running total that climbs in equal steps, the mean at the midpoint, the variance, and the mode and median. The last row works through a fair six-sided die.
DownloadPNG2×PDF
AspectFormula or statementNote or example
ParametersThe two endpoints that fix the distribution, as the parameters section explains.aa, the minimum, and bb, the maximum; n=b−a+1n = b - a + 1 valuesaa and bb are integers with a≤ba \leq b
SupportEvery whole number from aa to bb, set out with the PMF and its support.{a,a+1,…,b}\{a, a + 1, \ldots, b\}finite, equally spaced integers
PMFThe probability of each single value, from the PMF section.P(X=x)=1b−a+1=1n,x∈{x1,x2,…,xn}\displaystyle P(X = x) = \frac{1}{b - a + 1} = \frac{1}{n}, \quad x \in \{x_1, x_2, \dots, x_n\}every value carries the same probability mass
CDFThe probability of a value up to xx, from the CDF section.FX(x)=P(X≤x)={0,x<a⌊x⌋−a+1b−a+1,a≤x≤b1,x>b\displaystyle F_X(x) = P(X \leq x) = \begin{cases} 0, & x < a \\ \frac{\lfloor x \rfloor - a + 1}{b - a + 1}, & a \leq x \leq b \\ 1, & x > b \end{cases}a step function jumping by 1/n1/n at each integer
Expected valueThe balance point of the values, derived in the expected value section.E[X]=a+b2\displaystyle E[X] = \frac{a + b}{2}the midpoint of the range; not always a value the variable can take
VarianceHow widely the values spread around the midpoint, worked out in variance and standard deviation.Var(X)=(b−a+1)2−112=n2−112\displaystyle \mathrm{Var}(X) = \frac{(b - a + 1)^2 - 1}{12} = \frac{n^2 - 1}{12}grows quadratically with the width of the range
Mode and medianNo value is more likely than another, and the middle sits at the midpoint, as mode and median shows.every value is a mode; Median=a+b2\displaystyle \text{Median} = \frac{a + b}{2}, an interval when nn is eventhe distribution is fully symmetric and flat
Canonical exampleThe fair die the page keeps returning to; variance and standard deviation finishes its numbers.a fair six-sided die: a=1a = 1, b=6b = 6, n=6n = 6E[X]=3.5E[X] = 3.5, Var(X)=3512≈2.92\displaystyle \mathrm{Var}(X) = \frac{35}{12} \approx 2.92, σ≈1.71\sigma \approx 1.71
Discrete uniform distribution at a glance·All probability formulasLearn Math Class
Nearly every formula on the card starts from one count, the number of values from the smallest to the largest, which is one more than their difference. Getting that count right first keeps the probability, the running total and the variance right with it.

Common Pitfalls

Three mistakes account for most wrong answers in discrete uniform problems. Each one is marked where it happens in the sections above; here each is worked through in full, with the wrong and the right working side by side.
DownloadPNG2×PDF
1Forgetting to count both ends
The number of values is taken as the distance b−ab - a between the bounds, so one of the two endpoints is left out of the count.
Wrong turn
Error here
For the integers from 1010 to 2020,
n=20−10=10,P(X=x)=110n = 20 - 10 = 10, \qquad P(X = x) = \frac{1}{10}
Right path
Both 1010 and 2020 are possible values, so the count is one more than the distance.
n=20−10+1=11,n = 20 - 10 + 1 = 11,

P(X=x)=111P(X = x) = \frac{1}{11}
Why it happensSubtracting the bounds measures the length of the range, and on the standard die starting at 11 the slip is hidden, because the count 66 is also the upper bound. Once the lower bound is not 11, length and count differ by one.
How to checkThe probabilities must add up to 11. With the wrong count, the 1111 values each get 110\frac{1}{10}, and 11×110=1.111 \times \frac{1}{10} = 1.1. With the right count, 11×111=111 \times \frac{1}{11} = 1.
2Treating at least as more than
The question asks for at least kk, and the complement is taken at kk instead of at k−1k - 1, so the value kk itself is left out.
Wrong turn
Error here
For a fair die,
P(X≥3)=1−FX(3)=1−36=12P(X \geq 3) = 1 - F_X(3) = 1 - \frac{3}{6} = \frac{1}{2}
Right path
At least 33 means 33, 44, 55 or 66, so the complement is at most 22.
P(X≥3)=1−FX(2)=1−26P(X \geq 3) = 1 - F_X(2) = 1 - \frac{2}{6}

=23= \frac{2}{3}
Why it happensThe rules for "more than" and "at least" differ by a single value, and for continuous variables the difference between >> and ≥\geq never matters, so the habit of ignoring it carries over.
How to checkCount the values in the event and divide by nn. The faces 3,4,5,63, 4, 5, 6 are four of six, so the answer is 46=23\frac{4}{6} = \frac{2}{3}.
3Using the continuous variance formula
The variance of the continuous uniform on [a,b][a, b], (b−a)212\frac{(b - a)^2}{12}, is used for the discrete uniform on {a,a+1,…,b}\{a, a + 1, \ldots, b\}.
Wrong turn
Error here
For a fair die,
Var(X)=(6−1)212=2512≈2.083\mathrm{Var}(X) = \frac{(6 - 1)^2}{12} = \frac{25}{12} \approx 2.083
Right path
The discrete formula uses the number of values n=b−a+1=6n = b - a + 1 = 6.
Var(X)=n2−112=36−112\mathrm{Var}(X) = \frac{n^2 - 1}{12} = \frac{36 - 1}{12}

=3512≈2.917= \frac{35}{12} \approx 2.917
Why it happensBoth distributions are called uniform, both formulas have 1212 in the denominator, and the continuous one is shorter and easier to remember.
How to checkCompute the variance directly from the definition. The mean is 3.53.5, and the squared distances of the six faces from it are 6.25,2.25,0.25,0.25,2.25,6.256.25, 2.25, 0.25, 0.25, 2.25, 6.25. Their average is 17.56=3512≈2.917\frac{17.5}{6} = \frac{35}{12} \approx 2.917.
Common pitfalls with the discrete uniform distribution·/probability/distributions/discrete/uniformLearn Math Class
Each slip miscounts the values from aa to bb. There are b−a+1b - a + 1 of them, at least kk includes kk itself, and the variance is n2−112\frac{n^2 - 1}{12}, not the continuous (b−a)212\frac{(b - a)^2}{12}. Counting the values directly, or computing the variance from the definition, catches each slip.

Skills You Should Learn

Each skill opens its step-by-step method page. Skills marked "On this page" are taught above.
Taught on this page
More distribution methods

Discrete Uniform Distribution FAQ

Why is the denominator b − a + 1 and not b − a?

+
Because it counts outcomes, not width. The integers from a to b inclusive number b − a + 1 — six faces from 1 to 6, not five. Writing 1/(b − a) is the fencepost error in probabilistic dress: on DU(1, 6) it hands each face 1/5 and the six probabilities sum to 1.2. The slip hides on DU(1, n), where the count collapses to 1/n.Read more →

Does U(a, b) mean the discrete or continuous uniform?

+
Bare U(a, b) names both with equal authority, and nothing in the parentheses distinguishes them. U(3, 7) can mean five equally likely integers, each with probability 1/5, or an interval of infinitely many points, each with probability 0. Two tells resolve it: a pmf and integer bounds mean discrete; a density and real bounds mean continuous.Read more →

What does the support line tell you about a distribution?

+
Often the family, before the formula does. Braces {a, a+1, …, b} mean a stepped integer run; brackets [a, b] mean a real interval. Among the discrete families the shapes differ too: a closed list for the binomial, an open ellipsis for the Poisson, computed clamps for the hypergeometric, a shifted list for the negative binomial.Read more →

What is the German tank problem?

+
It is estimating the top of a discrete uniform range from a few draws. In World War II, Allied statisticians treated captured serial numbers as draws from 11 to NN and estimated NN from the largest number seen, mm, and how many were seen, kk; the usual modern estimate is m+mk−1m + \frac{m}{k} - 1. For tanks built in August 1942 they got 327, against intelligence reports of 1,550; German records later showed 342.Read more →

Can loaded dice make the sum of two dice uniform?

+
No, whatever the weights. Every total from 22 to 1212 would need probability 111\frac{1}{11}, so p1q1=p6q6=111p_1 q_1 = p_6 q_6 = \frac{1}{11}, where pip_i and qiq_i are the face probabilities of the two dice. But a total of 77 includes the rolls (1, 6) and (6, 1), and p1q6+p6q1≥2p1q1 p6q6=211p_1 q_6 + p_6 q_1 \geq 2\sqrt{p_1 q_1 \, p_6 q_6} = \frac{2}{11}, already twice the share it is allowed.Read more →

Do the values of a discrete uniform have to be consecutive integers?

+
No, any nn distinct values can share probability 1n\frac{1}{n} each, such as a die whose faces read 2, 3, 5, 7, 11, 13. The family DU⁡(a,b)\operatorname{DU}(a, b) and its formulas, though, assume the consecutive integers from aa to bb. For equally spaced values with step hh the mean is still the midpoint and the variance becomes h2⋅n2−112h^2 \cdot \frac{n^2 - 1}{12}; for an irregular set, compute both from the definition.Read more →