For $X \sim U(a,b)$, $V(X) = \frac{(b-a)^2}{12}$, but I have seen some sources have it as $\frac{1}{12}(b-a)(b-a+2)$. In fact, a question simply asked me to prove the that variance is $\frac{1}{12}(b-a)(b-a+2)$ given the uniform distribution.
I am able to successfully prove it to be $\frac{(b-a)^2}{12}$ but I'm not sure where that $2$ term can come from. When I look online, I actually see BOTH these on google images, but no explanation of the difference.
Can someone explain?
The difference is between two different distributions
1.
$$X\sim U(a,b)$$
2.
$$Y\sim U\{a;b\}$$
is a continuous distribution and its variance is $\mathbb{V}[X]=\frac{(b-a)^2}{12}$
is a discrete distribution with variance $\mathbb{V}[Y]=\frac{n^2-1}{12}=\frac{(b-a)(b-a+2)}{12}$
If you want to prove $V(Y)$ the easiest way is to consider a shifted rv
$$Y\sim U\{1;n\}$$
and calculate
$$\mathbb{E}[Y]=\frac{1}{n}\sum_{i=1}^{n} i=\frac{n+1}{2}$$
$$\mathbb{E}[Y^2]=\frac{1}{n}\sum_{i=1}^{n} i^2=\frac{(n+1)(2n+1)}{6}$$
and thus
$$\mathbb{V}[Y]=\frac{(n+1)(2n+1)}{6}-\left(\frac{n+1}{2}\right)^2=\dots=\frac{n^2-1}{12}$$
this is enough for your proof being
$$n=b-a+1$$
and thus
$$n^2-1=(b-a)(b-a+2)$$