next up previous
Next: About this document ...


12.3: Expected Value and Variance

If $X$ is a random variable with corresponding probability density function $f(x)$, then we define the expected value of $X$ to be


\begin{displaymath}E(X) := \int_{-\infty}^\infty x f(x) dx\end{displaymath}

We define the variance of $X$ to be

\begin{eqnarray*}
\mathrm{Var}(X) & := & \int_{-\infty}^\infty [x - E(X)]^2 f(x) dx
\end{eqnarray*}


Alternate formula for the variance

As with the variance of a discrete random variable, there is a simpler formula for the variance.

\begin{eqnarray*}
\mathrm{Var}(X) & = & \int_{-\infty}^\infty [x - E(X)] f(x) dx...
...2 \times 1 \\
& = & \int_{-\infty}^\infty x^2 f(x) dx - E(X)^2
\end{eqnarray*}


Interpretation of the expected value and the variance

The expected value should be regarded as the average value. When $X$ is a discrete random variable, then the expected value of $X$ is precisely the mean of the corresponding data.

The variance should be regarded as (something like) the average of the difference of the actual values from the average. A larger variance indicates a wider spread of values.

As with discrete random variables, sometimes one uses the standard deviation, $\sigma = \sqrt{\mathrm{Var}(X)}$, to measure the spread of the distribution instead.


Example

The uniform distribution on the interval $[0,1]$ has the probability density function

\begin{displaymath}f(x) = \begin{cases}0 \text{ if } x < 0 \text{ or } x > 1 \\
1 \text{ if } 0 \leq x \leq 1 \end{cases} \end{displaymath}

Letting $X$ be the associated random variable, compute $E(X)$ and $\mathrm{Var}(X)$.


Solution

\begin{eqnarray*}
E(X) & = & \int_{-\infty}^\infty x f(x) dx \\
& = & \int_{-\...
... = & 0 + \frac{1}{2} x^2 \vert_{0}^1 + 0 \\
& = & \frac{1}{2}
\end{eqnarray*}


Solution, continued

We compute

\begin{eqnarray*}
\int_{-\infty}^\infty x^2 f(x) dx & = & \int_0^1 x^2 dx \\
& = & \frac{1}{3} x^3 \vert_{x=0}^{x=1} \\
& = & \frac{1}{3}
\end{eqnarray*}


Solution, completed

Hence,

\begin{eqnarray*}
\mathrm{Var}(X) & = & \int_{-\infty}^\infty x^2 f(x) dx - E(X)^2 \\
& = & \frac{1}{3} - \frac{1}{4} \\
& = & \frac{1}{12}
\end{eqnarray*}


Another example

Let $X$ be the random variable with probability density function $f(x) = \begin{cases}e^x \text{ if } x \leq 0 \\
0 \text{ if } x > 0 \end{cases}$.

Compute $E(X)$ and $\mathrm{Var}(X)$.


Solution

Integrating by parts with $u = x$ and $dv = e^x dx$, we see that $\int x e^x dx = x e^x - e^x + C$. Thus,

\begin{eqnarray*}
E(X) & = & \int_{-\infty}^\infty x f(x) dx \\
& = & \int_{-\...
...\\
& = & \lim_{r \to -\infty} [-1 - r e^r + e^r] \\
& = & 1
\end{eqnarray*}

[We used L'Hôpital's rule to see that $\lim_{r \to -\infty} r e^r =
\lim_{r \to -\infty} \frac{r}{e^{-r}} = \lim_{r \to -\infty} \frac{1}{-e^{-r}} = 0$.]


Solution, continued

We compute

\begin{eqnarray*}
\int x^2 e^x dx & = & x^2 e^x - 2 \int x e^x dx \\
& = & x^2 e^x - 2x e^x + 2 e^x + C
\end{eqnarray*}

So,

\begin{eqnarray*}
\int_{-\infty}^\infty x^2 f(x) dx & = & \int_{-\infty}^0 x^2 e...
...lim_{r \to -\infty} (2 - r^2 e^r + 2 r e^r - 2 e^r) \\
& = & 2
\end{eqnarray*}

This gives $\mathrm{Var}(X) = 2 - 1^2 = 1$.


One more example

Suppose that the random variable $X$ has a cumulative distribution function

$F(x) = \begin{cases}\sin(x) \text{ if } 0 \leq x \leq \frac{\pi}{2} \\
0 \text{ if } x < 0 \text{ or } x > \frac{\pi}{2}
\end{cases}$

Compute $E(X)$ and $\mathrm{Var}(X)$.


Solution

First, we must find the probability density function of $X$. Differentiating we find that the function


\begin{displaymath}f(x) = \begin{cases}\cos(x) \text{ if } 0 \leq x \leq \frac{\pi}{2} \\
0 \text{ otherwise }
\end{cases}\end{displaymath}

is the derivative of $F$ at all but two points. Thus, $f(x)$ is a probability density function for $X$.


Solution, continued

\begin{eqnarray*}
E(X) & = & \int_{-\infty}^\infty x f(x) dx \\
& = & \int_0^{...
...(x)) \vert_{x=0}^{x=\frac{\pi}{2}} \\
& = & \frac{\pi}{2} - 1
\end{eqnarray*}


Solution, finished

Integrating by parts, we compute

\begin{eqnarray*}
\mathrm{Var}(X) & = & \int_0^\frac{\pi}{2} x^2 \cos(x) dx - E(...
...c{\pi^2}{4} - 2 - (\frac{\pi^2}{4} - \pi + 1) \\
& = & \pi - 3
\end{eqnarray*}




next up previous
Next: About this document ...
Thomas Scanlon 2004-05-05