## The Uniform Distribution of the First N Natural Numbers

Suppose $X$ is a discrete random variable following a uniform distribution with outcome space of $S = \{1,2,\ldots,N\}$.

We will show the following formulas hold: $$E(X) = \frac{N+1}{2} \quad \quad \textrm{ and } \quad \quad Var(X) = \frac{N^2 - 1}{12}$$

The arguments for both are very direct and involve little more than algebra and knowledge of two basic summation formulas: $$\sum_{i=1}^n i = \frac{n(n+1)}{2} \quad \quad \textrm{ and } \quad \quad \sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6}$$

First, let us consider the expected value of $X$:

$$\begin{array}{rcl} E(X) &=& \displaystyle{\sum_{x \in S} x \cdot P(x)}\\\\ &=& \displaystyle{\sum_{i = 1}^n i \cdot \frac{1}{N}}\\\\ &=& \displaystyle{\frac{1}{N} \cdot \sum_{i = 1}^n i}\\\\ &=& \displaystyle{\frac{1}{N} \cdot \frac{N(N+1)}{2}}\\\\ &=& \displaystyle{\frac{N+1}{2}} \end{array}$$

Then, to find the variance of $X$, we attack things similarly...

$$\begin{array}{rcl} Var(X) &=& \displaystyle{E[X^2] - \mu^2}\\\\ &=& \displaystyle{\sum_{x \in S} \left[ x^2 \cdot P(x) \right] - \left( \frac{N+1}{2} \right)^2 }\\\\ &=& \displaystyle{\sum_{i = 1}^N \left[ i^2 \cdot \frac{1}{N} \right] - \frac{(N+1)^2}{4}}\\\\ &=& \displaystyle{\frac{1}{N} \cdot \sum_{i = 1}^N i^2 - \frac{(N+1)^2}{4}}\\\\ &=& \displaystyle{\frac{1}{N} \cdot \frac{N(N+1)(2N+1)}{6} - \frac{(N+1)^2}{4}}\\\\ &=& \displaystyle{\frac{2(N+1)(2N+1)}{12} - \frac{3(N+1)^2}{12}}\\\\ &=& \displaystyle{\frac{(N+1)((4N+2) - (3N+3))}{12}}\\\\ &=& \displaystyle{\frac{(N+1)(N-1)}{12}}\\\\ &=& \displaystyle{\frac{N^2-1}{12}}\\\\ \end{array}$$