# 2.5 Expected Value, Variance, and Standard Deviation

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Analogous to the discrete case, we can define the expected value, variance, and standard deviation of a continuous random variable. These quantities have the same interpretation as in the discrete setting. The expectation of a random variable is a measure of the center of the distribution, its mean value. The variance and standard deviation are measures of the horizontal spread or dispersion of the random variable.

Expected Value of a Continuous Random Variable
The expected value (also called the expectation or mean) of a continuous random variable X,

with probability density function f(x), is the number given by

$\mathbb{E}(X) = \int_{-\infty}^{\infty} x f(x) dx$.
Variance and Standard Deviation of a Continuous Random Variable
The variance of a continuous random variable X, with probability density function f(x) is:
$\text{Var}(X) = \int_{-\infty}^{\infty} \big(x - \mathbb{E}(X)\big)^2 f(x) dx$.

As in the discrete case, the standard deviation, σ, is the positive square root of the variance:

$\sigma(X) = \sqrt{\text{Var}(X)}$.

## Simple Example

A random variable X is given by the following PDF. Check that this is a valid PDF and calculate the standard deviation of X.

$f(x) = \begin{cases} 2 (1 - x) & \text{if } 0 \le x \le 1,\\ 0 & \text{otherwise} \end{cases}$

### Solution

#### Part 1

To verify that f(x) is a valid PDF, we must check that it is everywhere nonnegative and that it integrates to 1.

We see that 2(1-x) = 2 - 2x ≥ 0 precisely when x ≤ 1; thus f(x) is everywhere nonnegative.

To check that f(x) has unit area under its graph, we calculate

\begin{align} \int_{-\infty}^{\infty} f(x) dx = 2 \int_{0}^{1} (1 - x) dx =2 \Big( x - \frac{x^2}{2} \Big) \Big|_0^1=1 \end{align}

So f(x) is indeed a valid PDF.

#### Part 2

To calculate the standard deviation of X, we must first find its variance. Calculating the variance of X requires its expected value:

\begin{align} \mathbb{E}(X) &= \int_{-\infty}^{\infty} x f(x) dx \\ &= \int_{0}^{1} x \Big[ 2 (1 - x) \Big] dx \\ &= 2 \int_{0}^{1} \Big( x - x^2 \Big) dx \\ &= 2 \Big( \frac{x^2}{2} - \frac{x^3}{3} \Big) \Big|_0^1 \\ &= 1/3 \end{align}

Using this value, we compute the variance of X as follows

\begin{align} \text{Var}(X) &= \int_{-\infty}^{\infty} \big(x - \mathbb{E}(X)\big)^2 f(x) dx \\ &= \int_0^1 \big( x - 1/3\big)^2\cdot 2(1-x) dx \\ &= 2 \int_0^1\big( x^2 -\frac{2}{3} x + \frac{1}{9} \big) (1-x) dx \\ &= 2 \int_0^1\big( -x^3 + \frac{5}{3}x^2 -\frac{7}{9} x +\frac{1}{9} \big) dx \\ &= 2 \big( -\frac{1}{4}x^4 + \frac{5}{9}x^3 -\frac{7}{18} x^2 +\frac{1}{9}x \big)\Big|_0^1 \\ &= 2 \big( -\frac{1}{4} + \frac{5}{9} -\frac{7}{18} +\frac{1}{9} \big) \\ &= \frac{1}{18} \end{align}

Therefore, the standard deviation of X is

\begin{align} \sigma &= \sqrt{\text{Var}(X)}\\ &= \frac 1{3\sqrt{2}} \end{align}

### An Alternative Formula for Variance

There is an alternative formula for the variance of a random variable that is less tedious than the above definition.

Alternate Formula for the Variance of a Continuous Random Variable
The variance of a continuous random variable X with PDF f(x) is the number given by
$\text{Var}(X) = \mathbb{E}(X^2) - [\mathbb{E}(X)]^2$.

The derivation of this formula is a simple manipulation and has been relegated to the exercises. We should note that a completely analogous formula holds for the variance of a discrete random variable, with the integral signs replaced by sums.

## Simple Example Revisited

We can use this alternate formula for variance to find the standard deviation of the random variable X defined above.

Remembering that the expectation of X was found to be 1/3, we compute the variance of X as follows:

\begin{align} \text{Var}(X) &= \mathbb{E}(X^2) - [\mathbb{E}(X)]^2\\ &= \int_{-\infty}^{\infty} x^2 f(x) dx - \left(\frac 13\right)^2 \\ &= 2 \int_0^1 x^2 (1-x) dx - \frac{1}{9}\\ &= 2 \int_0^1\big( x^2 - x^3 \big) dx- \frac{1}{9} \\ &= 2 \big( \frac{1}{3}x^3 - \frac{1}{4}x^4 \big) \big|_0^1 - \frac{1}{9} \\ &= 2 \big( \frac{1}{3} - \frac{1}{4} \big) - \frac{1}{9} \\ &= \frac{1}{18} \end{align}

In the exercises, you will compute the expectations, variances and standard deviations of many of the random variables we have introduced in this chapter, as well as those of many new ones.