# Discrete uniform distribution

(Redirected from Uniform distribution (discrete))

In probability theory and statistics, the discrete uniform distribution is a symmetric probability distribution whereby a finite number of values are equally likely to be observed; every one of n values has equal probability 1/n. Another way of saying "discrete uniform distribution" would be "a known, finite number of outcomes equally likely to happen".

Notation Probability mass functionn = 5 where n = b − a + 1 Cumulative distribution function ${\displaystyle {\mathcal {U}}\{a,b\}}$ or ${\displaystyle \mathrm {unif} \{a,b\}}$ ${\displaystyle a\in \{\dots ,-2,-1,0,1,2,\dots \}\,}$${\displaystyle b\in \{\dots ,-2,-1,0,1,2,\dots \},b\geq a}$${\displaystyle n=b-a+1\,}$ ${\displaystyle k\in \{a,a+1,\dots ,b-1,b\}\,}$ ${\displaystyle {\frac {1}{n}}}$ ${\displaystyle {\frac {\lfloor k\rfloor -a+1}{n}}}$ ${\displaystyle {\frac {a+b}{2}}\,}$ ${\displaystyle {\frac {a+b}{2}}\,}$ N/A ${\displaystyle {\frac {(b-a+1)^{2}-1}{12}}}$ ${\displaystyle 0\,}$ ${\displaystyle -{\frac {6(n^{2}+1)}{5(n^{2}-1)}}\,}$ ${\displaystyle \ln(n)\,}$ ${\displaystyle {\frac {e^{at}-e^{(b+1)t}}{n(1-e^{t})}}\,}$ ${\displaystyle {\frac {e^{iat}-e^{i(b+1)t}}{n(1-e^{it})}}}$

A simple example of the discrete uniform distribution is throwing a fair die. The possible values are 1, 2, 3, 4, 5, 6, and each time the dice is thrown the probability of a given score is 1/6. If two dice are thrown and their values added, the resulting distribution is no longer uniform since not all sums have equal probability.

The discrete uniform distribution itself is inherently non-parametric. It is convenient, however, to represent its values generally by all integers in an interval [a,b], so that a and b become the main parameters of the distribution (often one simply considers the interval [1,n] with the single parameter n). With these conventions, the cumulative distribution function (CDF) of the discrete uniform distribution can be expressed, for any k ∈ [a,b], as

${\displaystyle F(k;a,b)={\frac {\lfloor k\rfloor -a+1}{b-a+1}}}$

## Estimation of maximumEdit

This example is described by saying that a sample of k observations is obtained from a uniform distribution on the integers ${\displaystyle 1,2,\dotsc ,N}$ , with the problem being to estimate the unknown maximum N. This problem is commonly known as the German tank problem, following the application of maximum estimation to estimates of German tank production during World War II.

The uniformly minimum variance unbiased (UMVU) estimator for the maximum is given by

${\displaystyle {\hat {N}}={\frac {k+1}{k}}m-1=m+{\frac {m}{k}}-1}$

where m is the sample maximum and k is the sample size, sampling without replacement.[1] This can be seen as a very simple case of maximum spacing estimation.

This has a variance of[1]

${\displaystyle {\frac {1}{k}}{\frac {(N-k)(N+1)}{(k+2)}}\approx {\frac {N^{2}}{k^{2}}}{\text{ for small samples }}k\ll N}$

so a standard deviation of approximately ${\displaystyle {\tfrac {N}{k}}}$ , the (population) average size of a gap between samples; compare ${\displaystyle {\tfrac {m}{k}}}$  above.

The sample maximum is the maximum likelihood estimator for the population maximum, but, as discussed above, it is biased.

If samples are not numbered but are recognizable or markable, one can instead estimate population size via the capture-recapture method.

### DerivationEdit

For any integer m such that k ≤ m ≤ N, the probability that the sample maximum will be equal to m can be computed as follows. The number of different groups of k tanks that can be made from a total of N tanks is given by the binomial coefficient ${\displaystyle {\tbinom {N}{k}}}$ . Since in this way of counting the permutations of tanks are counted only once, we can order the serial numbers and take note of the maximum of each sample. To compute the probability we have to count the number of ordered samples that can be formed with the last element equal to m and all the other k-1 tanks less or equal to m-1. The number of samples of k-1 tanks that can be made from a total m-1 tanks is given by the binomial coefficient ${\displaystyle {\tbinom {m-1}{k-1}}}$ , so the probability of having a maximum m is ${\displaystyle P(m)={\tbinom {m-1}{k-1}}{\big /}{\tbinom {N}{k}}}$ .

Given the total number N and the sample size k, the expected value of the sample maximum is

{\displaystyle {\begin{aligned}\mu =\mathrm {E} [m]&=\sum _{m=k}^{N}m{\frac {\tbinom {m-1}{k-1}}{\tbinom {N}{k}}}\\&={\frac {1}{(k-1)!{\tbinom {N}{k}}}}\sum _{m=k}^{N}{\frac {m!}{(m-k)!}}\\&={\frac {k!}{(k-1)!{\tbinom {N}{k}}}}\sum _{m=k}^{N}{\tbinom {m}{k}}\\&=k{\frac {\tbinom {N+1}{k+1}}{\tbinom {N}{k}}}\\&={\frac {k(N+1)}{k+1}},\end{aligned}}}

where the hockey-stick identity ${\displaystyle \sum _{m=k}^{N}{\tbinom {m}{k}}={\tbinom {N+1}{k+1}}}$  was used.

From this equation, the unknown quantity N can be expressed in terms of expectation and sample size as

{\displaystyle {\begin{aligned}N&=\mu \left(1+k^{-1}\right)-1.\end{aligned}}}

By linearity of the expectation, it is obtained that

{\displaystyle {\begin{aligned}\mu \left(1+k^{-1}\right)-1&=\mathrm {E} \left[m\left(1+k^{-1}\right)-1\right],\end{aligned}}}

and so an unbiased estimator of N is obtained by replacing the expectation with the observation,

{\displaystyle {\begin{aligned}{\hat {N}}&=m\left(1+k^{-1}\right)-1.\end{aligned}}}

Besides being unbiased this estimator also attains minimum variance. To show this, first note that the sample maximum is a sufficient statistic for the population maximum since the probability P(m;N) is expressed as a function of m alone. Next it must be shown that the statistics m is also a complete statistic, a special kind of sufficient statistics (demonstration pending). Then the Lehmann–Scheffé theorem implies that ${\displaystyle {\hat {N}}}$  is the minimum-variance unbiased estimator of N.[2]

The variance of the estimator is calculated from the variance of the sample maximum

{\displaystyle {\begin{aligned}\mathrm {Var} [{\hat {N}}]&={\frac {(k+1)^{2}}{k^{2}}}\mathrm {Var} [m].\end{aligned}}}

The variance of the maximum is in turn calculated from the expected values of ${\displaystyle m}$  and ${\displaystyle m^{2}}$ . The calculation of the expected value of ${\displaystyle m^{2}}$  is,

{\displaystyle {\begin{aligned}\mathrm {E} [m^{2}]&=\sum _{m=k}^{N}m^{2}{\frac {\tbinom {m-1}{k-1}}{\tbinom {N}{k}}}\\&={\frac {1}{(k-1)!{\tbinom {N}{k}}}}\sum _{m=k}^{N}m{\frac {m!}{(m-k)!}}\\&={\frac {1}{(k-1)!{\tbinom {N}{k}}}}\sum _{m=k}^{N}(m+1-1){\frac {m!}{(m-k)!}}\\&={\frac {1}{(k-1)!{\tbinom {N}{k}}}}\sum _{m=k}^{N}{\frac {(m+1)!}{(m-k)!}}-{\frac {1}{(k-1)!{\tbinom {N}{k}}}}\sum _{m=k}^{N}{\frac {m!}{(m-k)!}}\end{aligned}}}

where the second term is the expected value of ${\displaystyle m}$ . The first term can be expressed in terms of k and N,

{\displaystyle {\begin{aligned}{\frac {1}{(k-1)!{\tbinom {N}{k}}}}\sum _{m=k}^{N}{\frac {(m+1)!}{(m-k)!}}&={\frac {(k+1)!}{(k-1)!{\tbinom {N}{k}}}}\sum _{m=k}^{N}{\tbinom {m+1}{k+1}}\\&={\frac {k(k+1)}{\tbinom {N}{k}}}\sum _{n=k+1}^{N+1}{\tbinom {n}{k+1}}\\&={\frac {k(k+1)}{\tbinom {N}{k}}}{\tbinom {N+2}{k+2}}\\&={\frac {k(N+2)(N+1)}{(k+2)}}\end{aligned}}}

where the replacement ${\displaystyle n=m+1}$  was made and the hockey-stick identity used. Replacing this result and the expectation of ${\displaystyle m}$  in the equation of ${\displaystyle E[m^{2}]}$ ,

{\displaystyle {\begin{aligned}\mathrm {E} [m^{2}]&={\frac {k(N+2)(N+1)}{(k+2)}}-{\frac {k(N+1)}{k+1}}\\&=k(N+1){\Big (}{\frac {N+2}{k+2}}-{\frac {1}{k+1}}{\Big )}\\&={\frac {k(N+1)(kN+k+N)}{(k+1)(k+2)}}\end{aligned}}}

The variance of ${\displaystyle m}$  is then obtained,

{\displaystyle {\begin{aligned}\mathrm {Var} [m]&=\mathrm {E} [m^{2}]-\mathrm {E} [m]^{2}\\&={\frac {k(N+1)}{(k+1)}}{\Big (}{\frac {kN+k+N}{k+2}}-{\frac {k(N+1)}{k+1}}{\Big )}\\&={\frac {k(N+1)}{(k+1)}}{\frac {(N-k)}{(k+2)(k+1)}}\\&={\frac {k(N+1)(N-k)}{(k+1)^{2}(k+2)}}\end{aligned}}}

Finally the variance of the estimator ${\displaystyle {\hat {N}}}$  can be calculated,

{\displaystyle {\begin{aligned}\mathrm {Var} [{\hat {N}}]&={\frac {(k+1)^{2}}{k^{2}}}\mathrm {Var} [m]\\&={\frac {(k+1)^{2}}{k^{2}}}{\frac {k(N+1)(N-k)}{(k+1)^{2}(k+2)}}\\&={\frac {(N+1)(N-k)}{k(k+2)}}.\end{aligned}}}

## Random permutationEdit

See rencontres numbers for an account of the probability distribution of the number of fixed points of a uniformly distributed random permutation.