Discrete Uniform Distribution

In Uniform Distribution we explore the continuous version of the uniform distribution where any number between α and β can be selected. There is also a discrete version of this distribution where α and β are integers and only integer values between these parameters can be selected. In fact, if we let N = β – α + 1, then the discrete uniform distribution determines the probability of selecting an integer between 1 and N at random. The probability density function f(x) and cumulative distribution function F(x) for this distribution are clearly

f(x) = 1/N          F(x) = x/N

for x in the set {1, 2, …, N}.

The inverse cumulative distribution function is

F1(p) = INT(Np)

Other key statistical properties are:

  • Mean = (N + 1) / 2
  • Median = (N + 1) / 2
  • Mode = any x, 1 ≤ x ≤ N
  • Variance = (N21) / 12
  • Skewness = 0
  • Kurtosis = -6(N2+1)/(5(N2-1))

Reference

Wikipedia (2019) Discrete uniform distribution
https://en.wikipedia.org/wiki/Discrete_uniform_distribution

7 thoughts on “Discrete Uniform Distribution”

  1. I believe the variance is (N^2 – 1)/12, not (N-1)^2/12.

    To demonstrate, enter {1,2,…,20} into A1:A20.

    Then VARP(A1:A20) is 33.25. And so is ((A20-A1+1)^2 – 1)/12.

    But ((A20-A1+1)-1)^2/12 = (A20-A1)^2/12 is 30.0833333333333.

    Reply
    • I wrote: “I believe the variance is (N^2 – 1)/12, not (N-1)^2/12.“

      I should say: according to the cited wikipage, namely https://en.wikipedia.org/wiki/Discrete_uniform_distribution .

      However, when I try to calculate α and β in a manner similar to that demonstrated for the continuous uniform distribution at https://www.real-statistics.com/other-key-distributions/uniform-distribution, var=(N-1)^2/12, which is equivalent to var=(β-α)^2/12, seems to work better.

      Is the Discrete_uniform_distribution wikipage wrong?

      Reply
      • Hi Joe,
        No, I don’t think that the Wikipedia page is wrong. I just made a mistake, possibly a typo.
        If N = 2, then (N-1)^2/2 = 1/2, while (N^2-1)/12 = 1/4. To check that 1/4 is correct, I placed the formula =RANDBETWEEN(1,2) in cell A1 and then highlighted range A1:Q206 and pressed Ctrl-R and Ctrl-D. Finally, I calculated =VAR.P(A1:Q206) and obtained the value .249992, indicating that 1/4 is the correct value.
        Charles

        Reply
        • Thanks for the confirmation. I forgot that I had demonstrated the correctness of
          var = (N^2-1)/12 in my first comment. Klunk!

          But then can you help me with calculating α and β.

          Based on the corrected formula for var, I believe that:
          β = mean + (SQRT(var+1) – 1)/2
          α = 2*mean – β, or equivalently α = mean – (SQRT(var+1) – 1)/2

          But with {1,2,…,20} in A1:A20, we calculate:
          B1: =AVERAGE(A1:A20) is 10.5
          B2: =VARP(A1:A20) is 33.25
          B5 (β): =B1+(SQRT(B2+1)-1)/2 is 12.9261749776799
          B6 (α): =2*B1-B5 is 8.07382502232009

          Even if we use VAR (sample var) instead of VARP, α=8 and β=13.

          Obviously, α and β are wrong, because we know that the distribution is 1 to 20.

          On the other hand, if we use the __continuous__ uniform distribution
          var = (β-α)^2/12, or equivalently sd = (β-α)/SQRT(12), I believe that:
          β = mean + sd*SQRT(12)/2
          α = 2*mean – b, or equivalently α = mean – sd*SQRT(12)/2

          Then we calculate:
          B3: =STDEVP(A1:A20) is 5.7662812973354
          B9 (β): =B1+B3*SQRT(12)/2 is 20.4874921777191
          B10 (α): =2*B1-B9 is 0.512507822280909

          If we use STDEV (sample sd) instead of STDEVP, as you do, α=0.253049234040404 and β=20.7469507659596.

          In either case, α and β are about right for the actual distsribution of 1 to 20.

          Am I miscalculating α and β with the discrete var?

          Or is there some reason why we must always use the continuous var/sd to derive α and β?

          Reply

Leave a Comment