WordGPT

Discrete uniform distribution

Discrete uniform distribution: equally likely whole numbers between a and b. With the default parameters (smallest value a = 1, largest value b = 6) its mean is 3.5 and its standard deviation 1.7078. Use the simulator below to draw samples and see it take shape.

Simulate it

Change the parameters, then draw random samples. The bars are the samples; the dots are the exact probabilities. With more samples the bars settle onto it.

Samples to draw

00.050.10.15123456x
Mean
sample - · exact 3.5
Standard deviation
sample - · exact 1.708

What is the discrete uniform distribution?

The discrete uniform distribution gives the same probability to each of the whole numbers from a to b. A fair die is a discrete uniform from 1 to 6, and so is picking a numbered ticket at random.

It is the model of pure randomness over a finite set, and the basis of random sampling and of every simulation that picks an index at random.

Where it is used

  • Rolling a fair die (1 to 6).
  • Drawing a numbered ticket or raffle number.
  • Picking a random item from a list by its index.
  • A roulette pocket number.
  • The day of the week a random date falls on.

Shape and parameters

All bars have the same height 1/(b − a + 1). The mean is the midpoint (a + b)/2 and the spread depends only on how many values there are.

What it assumes

  • A finite set of consecutive whole numbers.
  • Every value equally likely.

How it relates to other distributions

  • Uniform distribution: The continuous version, where every value in an interval is equally likely.

Common mistakes

  • Believing a real die, wheel or generator is exactly uniform without checking.
  • Off-by-one errors in software: SciPy's randint(a, b) excludes b.

How to work it out

  1. 1

    The probability mass function (the formula that gives the shape):

    P(X=k)=1b−a+1P(X=k)=\frac{1}{b-a+1}
  2. 2

    Its mean (the long-run average) and variance (the spread):

    μ=a+b2,σ2=(b−a+1)2−112\mu = \frac{a+b}{2},\qquad \sigma^2 = \frac{(b-a+1)^2-1}{12}
  3. 3

    Worked example with the default parameters (smallest value a = 1, largest value b = 6): For values from 1 to 6, what is the probability of getting at least 5?

    answer=0.3333\text{answer} = 0.3333
LaTeX source of the formulas on this page
\[ P(X=k)=\frac{1}{b-a+1} \]
\[ \mu = \frac{a+b}{2},\qquad \sigma^2 = \frac{(b-a+1)^2-1}{12} \]
\[ \text{answer} = 0.3333 \]

At a glance

PropertyValue
TypeDiscrete (counts)
Parameterssmallest value a; largest value b
Possible valuesa, a + 1, …, b
Mean3.5
Variance2.9167
Standard deviation1.7078
Example (smallest value a = 1, largest value b = 6)For values from 1 to 6, what is the probability of getting at least 5? Answer: 0.3333.

How to compute it in Excel, Python and R

ToolFunction
Excel / Google Sheets=1/(b-a+1) or =RANDBETWEEN(a, b) to simulate
Python (SciPy)scipy.stats.randint.pmf(k, a, b + 1)
R1/(b - a + 1) or sample(a:b, 1)

Questions

What is the discrete uniform distribution used for?

Equally likely whole numbers between a and b. Typical uses: Rolling a fair die (1 to 6). Drawing a numbered ticket or raffle number. Picking a random item from a list by its index.

What are the mean and variance of the discrete uniform distribution?

Mean: μ = (a+b)/(2). Variance: σ² = ((b-a+1)²-1)/(12).

What does the discrete uniform distribution assume?

A finite set of consecutive whole numbers. Every value equally likely.

How do I calculate it in Excel?

=1/(b-a+1) or =RANDBETWEEN(a, b) to simulate

How is the discrete uniform distribution related to other distributions?

Uniform distribution: The continuous version, where every value in an interval is equally likely.

Related distributions

Choosing a distribution

    Discrete uniform distribution: what it is, when to use it, formulas and simulator | WordGPT