# Prove variance in Uniform distribution (continuous)

I read in wikipedia article, variance is $\frac{1}{12}(b-a)^2$ , can anyone prove or show how can I derive this?

By the definition of the variance, $\operatorname{Var} X = \mathbb{E}[X^2] - (\mathbb{E} X)^2$.
Since here $\mathbb{E} X = \frac{1}{b-a}\int_{[a,b]}x dx = \frac{a+b}{2}$, and $\mathbb{E} X^2 = \frac{1}{b-a}\int_{[a,b]}x^2 dx = \frac{b^3-a^3}{3(b-a)}=\frac{a^2+ab+b^2}{3}$, it follows that $$\operatorname{Var} X = \frac{a^2+ab+b^2}{3} - \frac{a^2+2ab+b^2}{4} = \frac{a^2-2ab+b^2}{12} =\frac{(b-a)^2}{12}$$
Let $U$ uniform on $[-1,1]$. Then $X = \frac{a+b}2 + \frac{b-a}2 U$ (in law) and $$Var\ X = \frac{(b-a)^2}4 Var\ U\\ Var \ U = EU^2 =\frac 12 \int_{-1}^1x^2dx = \int_{0}^1x^2dx = \frac 13\\ Var\ X = \frac{(b-a)^2}{12}$$
Let $$U\sim \text{Unif}(0, 1)$$, then $$E(U) = \int_0^1 u\ du = \frac{1}{2}\ \text{and } E(U^2) = \int_0^1 u^2 du = \frac{1}{3}.$$ So that, $$V(U) = E(U^2) - \left[E(U)\right]^2 = 1/12$$.
Now let $$X \sim \text{Unif}(a, b)$$, then $$X = a + (b -a)U$$. From elementary probability theory, it follows that $$V(X) = (b - a)^2V(U) = \frac{(b - a)^2}{12}$$