Derive the variance of a uniform distribution.

Understanding
The following is the probability density function for a uniform distribution. The indicator function \(I\) is 1 over the interval \([a,b]\) and zero everywhere else.\[f(x)=\frac{1}{b-a}I(a\le x\le b)\] The variance of a random variable is related to the first and second moments as follows. \[\begin{align*} \mathop{Var}X&=E((X-EX)^2)\\ &=E(X^2-2X\,EX+(EX)^2)\\ &=E(X^2)-2(EX)(EX)+(EX)^2\\ &=E(X^2)-(EX)^2 \end{align*}\]

Method

 * 1) Compute the first moment, or mean.
 * 2) Set \(EX\) equal to the integral of \(xf(x)\) with respect to \(x\) from \(x=-\infty\) to \(x=+\infty\), as shown below: \[\begin{align*}EX&=\int_{-\infty}^\infty xf(x)\,dx\end{align*}\]
 * 3) Replace \(f(x)\) with \(\frac{1}{b-a}\) and change the interval of integration, as shown below:\[\begin{align*}&EX=\frac{1}{b-a}\int_a^bx\,dx\end{align*}\]
 * 4) Integrate the \(x\) with respect to \(x\) to get \(\frac{1}{2}x^2\) and write the range over which to evaluate this term, as shown below: \[\begin{align*}EX&=\frac{1}{b-a}\left.\left(\frac{1}{2}x^2\right)\right|_a^b\\&=\frac{1}{b-a}\cdot\frac{1}{2}(b^2-a^2)\\&=\frac{(b+a)(b-a)}{2(b-a)}\\&=\frac{a+b}{2}\end{align*}\]
 * 5) Compute the second moment.\[\begin{align*}E(X^2)&=\int_{-\infty}^\infty x^2f(x)\,dx\\&=\frac{1}{b-a}\int_a^b x^2\,dx\\&=\frac{1}{b-a}\left.\left(\frac{1}{3}x^3\right)\right|_a^b\\&=\frac{b^3-a^3}{3(b-a)}\end{align*}\]
 * 6) Compute the variance.\[\begin{align*}\mathop{Var}X&=E(X^2)-(EX^2)\\&=\frac{b^3-a^3}{3(b-a)}-\left(\frac{a+b}{2}\right)^2\\&=\frac{4(b^3-a^3)}{12(b-a)}-\frac{3(b-a)(a+b)^2}{12(b-a)}\\&=\frac{b^3-3ab^2+3a^2b-a^3}{12(b-a)}\\&=\frac{(b-a)^3}{12(b-a)}\\&=\frac{(b-a)^2}{12}\end{align*}\]

Everything else
Note that the above method section is not yet complete. The mathematical facts must be converted to a sequence of explicit commands, as demonstrated in the first step of the method section.

Navigation

 * Statistics
 * Mathematics
 * Topics (listed alphabetically)
 * Main Page