# Discrete uniform distribution

The discrete uniform distribution is a probability distribution that assigns the same probability, \( 1/n \), to each of a finite number \( n \) of distinct values, and zero probability to every other value.<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup> It describes situations with a finite list of equally likely outcomes, such as a fair die roll or a random draw from a numbered list, and it is the working distribution behind random integer generation in software and [Monte Carlo](https://www.edgepedia.org/monte-carlo) simulation.<sup>[2](https://mindspaneducation.com/learn/probability-and-statistics/uniform-distribution/)</sup><sup> • </sup><sup>[3](https://www.sciencedirect.com/topics/mathematics/discrete-uniform-distribution)</sup>

| Key fact | Detail |
|---|---|
| Probability mass function | \( f(x) = 1/n \) for each of the \( n \) allowed values \( x \in S \), zero elsewhere<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup> |
| Mean | \( \E(X) = a + \tfrac{1}{2}(n-1)h = \tfrac{1}{2}(a+b) \), the midpoint of the endpoints<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup> |
| Variance | \( \var(X) = \tfrac{1}{12}(n^2-1)h^2 \); for consecutive integers on \(\{1,\ldots,m\}\), \( (m^2-1)/12 \)<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup><sup> • </sup><sup>[4](https://www.math.ucla.edu/~plopez/Winter_26/170E/Lecture_notes.pdf)</sup> |
| Fair die | \( n = 6 \) gives \( \E(X) = 3.5 \) and \( \var(X) = 35/12 \approx 2.917 \)<sup>[2](https://mindspaneducation.com/learn/probability-and-statistics/uniform-distribution/)</sup> |
| Shape | Skewness 0; kurtosis \( \tfrac{3}{5}\tfrac{3n^2-7}{n^2-1} \), which approaches 1.8 as \( n \) grows<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup> |
| Limit | Converges to the continuous uniform distribution on the same interval as the step size decreases to 0<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup> |
| Software | MATLAB `unidrnd`, NumPy `Generator.integers`, and R `sample` all draw from it<sup>[5](https://www.mathworks.com/help/stats/uniform-distribution-discrete.html)</sup><sup> • </sup><sup>[6](https://numpy.org/doc/stable/reference/random/generated/numpy.random.Generator.integers.html)</sup> |

## Definition and parameterization

A random variable \( X \) has the discrete uniform distribution on a finite set \( S = \{x_1, x_2, \ldots, x_n\} \) when \( \Pr(X = x_i) = 1/n \) for every \( i \). The values in \( S \) need not be integers or evenly spaced; an Abaqus reference work, for example, illustrates the distribution with allowed values 1, 2, 4, and 8.5, each with equal probability.<sup>[7](https://docs.software.vt.edu/abaqusv2025/English/IhrComponentMap/ihr-c-Reference-DiscreteUniform.htm)</sup> The most common case, and the one treated by most textbooks, is a discrete interval of consecutive integers.<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup>

**Location-scale form.** The standard version puts equal weight on \( \{0, 1, \ldots, n-1\} \). Adding a location parameter \( a \) and a scale parameter \( h > 0 \) gives a distribution on \( S = \{a, a+h, a+2h, \ldots, a+(n-1)h\} \), so the support has \( n \) points starting at \( a \) with step size \( h \). When \( a \) is an integer and \( h = 1 \), the support is an ordinary integer interval, and the distribution can equivalently be parameterized by its endpoints \( a \) and \( b = a + (n-1)h \), with \( n = 1 + (b-a)/h \).<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup> The family is closed under location-scale transformations: if \( Y = c + wX \), then \( Y \) is again discrete uniform, with \( n \) points, location \( c + wa \), and scale \( wh \).<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup>

## Moments

For the distribution on \(\{1, \ldots, m\}\), the mean is \( (m+1)/2 \) and the variance is \( (m^2-1)/12 \).<sup>[4](https://www.math.ucla.edu/~plopez/Winter_26/170E/Lecture_notes.pdf)</sup> In the endpoint form, the mean is the average of the two endpoints, \( \tfrac{1}{2}(a+b) \), while the variance \( \tfrac{1}{12}(n^2-1)h^2 \) depends only on the number of points and the step size, not on where the interval sits.<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup> A frequent exam trap is confusing the discrete variance \( (n^2-1)/12 \) with the continuous uniform variance \( (b-a)^2/12 \).<sup>[2](https://mindspaneducation.com/learn/probability-and-statistics/uniform-distribution/)</sup>

The distribution is symmetric about its mean, so its skewness is 0 for every \( n \). Its kurtosis is \( \tfrac{3}{5}\tfrac{3n^2-7}{n^2-1} \), which falls toward 1.8 as \( n \) increases.<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup> The moment-generating function on \(\{1, \ldots, m\}\) is

\[ M_X(t) = \begin{cases} \dfrac{e^t(1 - e^{mt})}{m(1 - e^t)}, & t \neq 0, \\[4pt] 1, & t = 0. \end{cases} \]

<sup>[4](https://www.math.ucla.edu/~plopez/Winter_26/170E/Lecture_notes.pdf)</sup>

## Distribution and quantile functions

As for every discrete distribution, the cumulative distribution function is a step function: it rises by \( 1/n \) at each allowed value. In the location-scale form the CDF on \( [a, b] \) is \( F(x) = \tfrac{1}{n}\left(\lfloor (x-a)/h \rfloor + 1\right) \), and the quantile function is \( F^{-1}(p) = a + h(\lceil np \rceil - 1) \) for \( p \in (0, 1] \).<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup> MATLAB's documentation illustrates the staircase CDF for \( N = 10 \) with its `unidcdf` function.<sup>[5](https://www.mathworks.com/help/stats/uniform-distribution-discrete.html)</sup>

## Examples

**Fair die and roulette.** A fair six-sided die is the canonical example: each face has probability \( 1/6 \), the mean is 3.5, and the variance is \( 35/12 \).<sup>[2](https://mindspaneducation.com/learn/probability-and-statistics/uniform-distribution/)</sup> A European roulette wheel with 37 compartments, or a Las Vegas wheel with 38 (the numbers 0 to 36 plus the double zero), models the resting place of the ball as discrete uniform.<sup>[8](https://www.statistics4u.com/fundstat_eng/cc_distri_uniform_discrete.html)</sup>

**Random selection.** Drawing one card at random from a standard 52-card deck, or picking one item from a numbered list, follows a discrete uniform distribution whenever no outcome is favored.<sup>[9](https://probabilityplayground.com/discreteuniform)</sup> MATLAB's example draws a random sample of 10 positions from a list of 553 items with `unidrnd(553,1,10)`.<sup>[5](https://www.mathworks.com/help/stats/uniform-distribution-discrete.html)</sup>

**Simulation.** The distribution is frequently used in simulation studies, where a computer imitates a real process to avoid costly or impossible experiments; generating random numbers is the basic ingredient of such Monte Carlo methods.<sup>[3](https://www.sciencedirect.com/topics/mathematics/discrete-uniform-distribution)</sup> One textbook recipe converts a continuous uniform draw \( R \sim U(0,1) \) into a discrete uniform draw by computing \( S = (n+1)R \) and taking the integer part of \( S \).<sup>[3](https://www.sciencedirect.com/topics/mathematics/discrete-uniform-distribution)</sup>

## Generating discrete uniform random numbers

Software libraries expose the distribution directly. NumPy's `Generator.integers(low, high)` returns random integers from the discrete uniform distribution over \( [\text{low}, \text{high}) \), or over \( [\text{low}, \text{high}] \) when `endpoint=True`.<sup>[6](https://numpy.org/doc/stable/reference/random/generated/numpy.random.Generator.integers.html)</sup> R's `sample` function draws uniform random samples from a supplied vector of values.<sup>[10](https://stat4ds.rwth-aachen.de/pdf/DS_R_webAppendix.pdf)</sup>

Under the hood, producing an unbiased integer in an interval \( [0, s) \) from fixed-width random words is a real algorithmic problem, because \( 2^{L} \) random bit patterns rarely divide evenly by \( s \). The OpenBSD `arc4random_uniform` function uses the rejection method, discarding values below \( 2^{L} \bmod s \); it consumes fewer than two random words on average but always computes two remainder operations.<sup>[11](https://arxiv.org/abs/1805.10941)</sup> Daniel Lemire, a computer scientist then at the Université du Québec TÉLUQ, published an alternative in 2018 that avoids integer divisions with high probability; the Go programming language adopted it for its shuffle function, reporting about 30% better speed than the OpenBSD approach.<sup>[11](https://arxiv.org/abs/1805.10941)</sup> A naive floating-point method, multiplying a uniform value in \( [0,1) \) by \( s \), runs 10% to 30% slower and introduces a small bias.<sup>[11](https://arxiv.org/abs/1805.10941)</sup>

## Relation to other distributions and problems

The discrete uniform distribution is a special case of the categorical distribution, which allows unequal probabilities across the outcomes.<sup>[12](https://www.sciencedirect.com/topics/computer-science/bernoulli-distribution)</sup> As the step size \( h \) shrinks toward 0 with the endpoints fixed, the discrete uniform on the interval converges to the [continuous uniform distribution](https://www.edgepedia.org/continuous-uniform-distribution) on the same interval.<sup>[1](https://www.randomservices.org/random/special/UniformDiscrete.html)</sup>

The distribution also underlies the [German tank problem](https://www.edgepedia.org/german-tank-problem), in which Allied analysts in World War II estimated the total number \( N \) of enemy tanks from observed serial numbers. Assuming the tanks are labeled consecutively from 1, so the observed serial numbers are a sample from a discrete uniform distribution on \(\{1, \ldots, N\}\), the best linear unbiased estimator of \( N \) from \( k \) observations with maximum \( m \) is \( m(1 + 1/k) - 1 \).<sup>[13](https://arxiv.org/abs/2101.08162)</sup>

## Historical setting

The idea of equally likely outcomes comes from games of chance, the setting in which probability theory began. In the mid-17th century, an exchange of letters between [Blaise Pascal](https://www.edgepedia.org/blaise-pascal) and [Pierre de Fermat](https://www.edgepedia.org/pierre-de-fermat), prompted by gambling problems, laid the foundation for modern probability theory; earlier writers such as [Luca Pacioli](https://www.edgepedia.org/luca-pacioli), Gerolamo Cardano, and Nicolò Tartaglia had already attacked the problem of points, how to divide stakes in an interrupted game, by counting equally probable outcomes.<sup>[14](https://www.aps.org/apsnews/2009/07/pascal-letters-fermat-points)</sup><sup> • </sup><sup>[15](https://library.ethz.ch/en/collections-and-archives/platforms/virtual-exhibitions/Its-all-math-and-games/game-types/from-games-of-chance-to-probability-theory.html)</sup> The discrete uniform distribution is the formal descendant of that counting: it is the model of a physical chance device, such as a die, whose outcomes are symmetric.<sup>[16](https://direct.mit.edu/posc/article/31/6/771/117924/Chance-Combinatorics-The-Theory-that-History)</sup>

## References

1. [Discrete Uniform Distributions, Random Services (Bill Griffiths)](https://www.randomservices.org/random/special/UniformDiscrete.html)
2. [Uniform Distribution PDF, Mean, MindSpan Education](https://mindspaneducation.com/learn/probability-and-statistics/uniform-distribution/)
3. [Discrete Uniform Distribution, ScienceDirect Topics (Statistical Methods, Third Edition, Freund, Rudolf J., William J. Wilson, Donna L. Mohr)](https://www.sciencedirect.com/topics/mathematics/discrete-uniform-distribution)
4. [MATH 170E Lecture Notes, Introduction to Probability and Statistics, UCLA (Pablo López)](https://www.math.ucla.edu/~plopez/Winter_26/170E/Lecture_notes.pdf)
5. [Uniform Distribution (Discrete), MATLAB & Simulink, MathWorks](https://www.mathworks.com/help/stats/uniform-distribution-discrete.html)
6. [numpy.random.Generator.integers, NumPy v2.5 Manual](https://numpy.org/doc/stable/reference/random/generated/numpy.random.Generator.integers.html)
7. [Discrete-Uniform Distribution, Abaqus 2025 Reference Documentation](https://docs.software.vt.edu/abaqusv2025/English/IhrComponentMap/ihr-c-Reference-DiscreteUniform.htm)
8. [Discrete Uniform Distribution, Statistics4u](https://www.statistics4u.com/fundstat_eng/cc_distri_uniform_discrete.html)
9. [Probability Playground: The Discrete Uniform Distribution](https://probabilityplayground.com/discreteuniform)
10. [Data Science Appendix: R for Sampling Distributions, RWTH Aachen](https://stat4ds.rwth-aachen.de/pdf/DS_R_webAppendix.pdf)
11. [Daniel Lemire (2018). Fast Random Integer Generation in an Interval. ACM Transactions on Modeling and Computer Simulation / arXiv.](https://arxiv.org/abs/1805.10941)
12. [Bernoulli Distribution, ScienceDirect Topics](https://www.sciencedirect.com/topics/computer-science/bernoulli-distribution)
13. [Lessons from the German Tank Problem, arXiv](https://arxiv.org/abs/2101.08162)
14. [July 1654: Pascal's Letters to Fermat on the "Problem of Points", APS News](https://www.aps.org/apsnews/2009/07/pascal-letters-fermat-points)
15. [From games of chance to probability theory, ETH Library](https://library.ethz.ch/en/collections-and-archives/platforms/virtual-exhibitions/Its-all-math-and-games/game-types/from-games-of-chance-to-probability-theory.html)
16. [Chance Combinatorics: The Theory that History Forgot, Perspectives on Science, MIT Press](https://direct.mit.edu/posc/article/31/6/771/117924/Chance-Combinatorics-The-Theory-that-History)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: Physical world and mathematics › Mathematics and statistics › Statistics and probability › Probability theory › Probability distributions › Distribution families and classification › Discrete distribution families

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/discrete-uniform-distribution
