**Probability Mass Function:** Parameters are $a,b$, which represent the lower and upper bound of the distribution. The [[Sample space]] consists of $\{a,a+1, \dots ,b\}$, where each element is equally likely. ![[discrete-uniform-pmf.png|center|400]] A special case is when $a=b$ makes the [[Random Variable]] a constant. Although it is deterministic, we can still call it a r.v.. **Expectation:** We assume that the lower bound $a=0$. $ \begin{align} \mathbb E[X] &=\sum_x x*p_x(x) \tag{1}\\ &=\frac{1}{n+1} *\sum_x x \tag{2}\\ &=\frac{1}{n+1} *\frac{n*(n+1)}{2} \tag{3}\\[6pt] &=\frac{n}{2} \end{align} $ (2) Insert the constant for every $p_X(x)$ and pull it out of the sum. (3) Replace the sum term by $\frac{n(n+1)}{2}$. **Variance (Uniform starts at 0):** $ \begin{align} \mathrm{Var}(X) &= \mathbb E[X^2]- (\mathbb E[X])^2 \tag{1} \\[4pt] &=\Big( \sum_x x^2 *p_X(x) \Big)-\Big(\frac{n}{2}\Big)^2 \tag{2}\\[4pt] &=\Big( \sum_x x^2 *\frac{1}{n+1} \Big)-\Big(\frac{n}{2}\Big)^2 \tag{3}\\[4pt] &=\frac{1}{n+1}* \Big(\sum_x x^2\Big)-\Big(\frac{n}{2}\Big)^2 \tag{4}\\[4pt] &=\frac{1}{n+1}* \Big(0^2+1^2+ \dots +n^2 \Big)-\Big(\frac{n}{2}\Big)^2 \tag{5}\\[4pt] &=\frac{1}{n+1}* \Big(\frac{1}{6}n(n+1)*(2n+1) \Big)-\Big(\frac{n}{2}\Big)^2 \tag{6}\\[4pt] &= \frac{1}{12}n(n+2) \tag{7} \end{align} $ (2) The [[Expectation]] of a uniform starting at $0$ is $n \over 2$. (4) Each probability of the PMF has the same value $1 \over (n+1)$. This constant can be pulled out of the sum. (6) Express the series of squares differently. **Variance (Uniform starts at $a$):** $ \mathrm{Var}(X)=\frac{1}{12}n*(n+2) \quad \text{where } \space n=b-a $ ^e8b971