**PDF:** ![[continuous-uniform-distribution.png|center|400]] **Expectation:** We derive the [[Expectation]] by integrating over the range of $[a,b]$. $ \begin{align} \mathbb E[X] &= \int_{-\infty}^\infty x * f_X(x) * dx \tag{1}\\[6pt] &= \int_{a}^b x * \frac{1}{b-a} * dx \tag{2}\\[6pt] &= \Big(\frac{b^2}{2}*\frac{1}{b-a}\Big) - \Big(\frac{a^2}{2}*\frac{1}{b-a}\Big) \tag{3} \\[6pt] &= \frac{b^2-a^2}{2(b-a)} \tag{4} \\[6pt] &= \frac{(b-a)*(b+a)}{2 (b-a)} \tag{5}\\[6pt] &= \frac{a+b}{2} \tag{6} \end{align} $ where: - (2) We only need to evaluate between $[a,b]$. Also the density $f_X(x)=\frac{1}{b-a}$ in that range. - (3) Evaluate the integral. **Variance:** We will use the [[Variance#^559043|method of moments]] formula to derive variance. Firstly we calculate the second moment of $X$. $ \begin{align} \mathbb E[X^2] &= \int_{-\infty}^\infty x^2 * f_X(x) * dx \\[6pt] &= \int_a^b x^2 * \frac{1}{b-a} * dx \\[6pt] &= \frac{1}{b-a}*\Big(\frac{b^3}{3}-\frac{a^3}{3} \Big) \end{align} $ Then we plug this into the method of moments formula.. $ \begin{align} \mathrm{Var}(X) & =\mathbb E[X^2]- (\mathbb E[X]^2) \\[4pt] &=\frac{1}{b-a}*\Big(\frac{b^3}{3}-\frac{a^3}{3} \Big) - \Big(\frac{a+b}{2}\Big)^2 \\[10pt] &=\frac{(b-a)^2}{12} \end{align} $ **Note:** This is slightly different from the variance for a [[Discrete Uniform Distribution#^e8b971|discrete uniform distribution]].