# 2.5 Expected Value, Variance, and Standard Deviation

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

${\displaystyle \mathbb {E} (X)=\int _{-\infty }^{\infty }xf(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:
${\displaystyle {\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:

${\displaystyle \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.

${\displaystyle f(x)={\begin{cases}2(1-x)&{\text{if }}0\leq x\leq 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

{\displaystyle {\begin{aligned}\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{aligned}}}

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:

{\displaystyle {\begin{aligned}\mathbb {E} (X)&=\int _{-\infty }^{\infty }xf(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{aligned}}}

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

{\displaystyle {\begin{aligned}{\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{aligned}}}

Therefore, the standard deviation of X is

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

### 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
${\displaystyle {\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:

{\displaystyle {\begin{aligned}{\text{Var}}(X)&=\mathbb {E} (X^{2})-[\mathbb {E} (X)]^{2}\\&=\int _{-\infty }^{\infty }x^{2}f(x)dx-\left({\frac {1}{3}}\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{aligned}}}

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.