×

# Variance

A random variable is a variable that whose value can change under different outcomes. For example, the result of flipping a standard 6-sided die is a random variable that takes each of the values from 1 to 6 with probability $$\frac{1}{6}.$$

A random variable contains a lot of information. In Expected Value, we learned that the weighted average of all possible outcomes gives one way of understanding the random variable. Recall that $$E[X] = \mu$$.

The variance of a random variable measures how far the random variable deviates from its mean, by calculating the expected value of the square deviation from the mean. In mathematical symbols, we have

$Var (X) = E[ ( X - \mu)^2 ].$

It can also be shown, by the linearity of expectation, that

$Var (X) = E[X^2] - \left( E[X] \right)^2 .$

## Worked Examples

### 1. There are $$2$$ bags, containing balls numbered $$1$$ through $$5$$. From each bag, $$1$$ ball is removed. What is the variance of the total of the two balls?

Let $$X$$ be the random variable denoting the sum of these values. Then, the probability distribution of $$X$$ is given by

$\begin{array} { | l | l | l | l | l | l | l | l | l | l l | } \hline x & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & \\ \hline P(X=x) & \frac{1}{25} & \frac{2}{25} & \frac{3}{25} & \frac{4}{25} & \frac{5}{25} & \frac{4}{25} & \frac{3}{25} & \frac{2}{25} & \frac{1}{25} & \\ \hline \end{array}$

We have previously calculated that $$E[X] = 6.$$ As such, we can see that

\begin{align} Var(X) & = E[(X - \mu)^2] \\ & = (2-6)^2 \times \frac {1}{25} + (3-6)^2 \times \frac {2}{25} + (4-6)^2 \times \frac {3}{25} \\ & + (5-6)^2 \times \frac {4}{25} + (6-6)^2 \times \frac {5}{25} + (7-6)^2 \times \frac {4}{25} \\ & + (8-6)^2 \times \frac {3}{25} + (9-6)^2 \times \frac {2}{25} + (10-6)^2 \times \frac {1}{25} \\ & = 4. \end{align}

## 2. $$3$$ six-sided dice are rolled. What is the variance for the number of times a $$3$$ is rolled? What is the variance for the total of the dice?

Let $$Y$$ be the random variable representing the number of times a $$3$$ is rolled. The below table lists the probabilities of rolling different numbers of $$3$$s.

$\begin{array}{|c|cccc|} \hline \mbox{num 3s} & 0 & 1 & 2 & 3\\ \mbox{probability } & \frac{125}{216} & \frac{75}{216} & \frac{15}{216} & \frac{1}{216}\\ \hline \end{array}$

The expected number of times a $$3$$ is rolled is $$\frac{1}{2}$$, so $$E(Y) = \frac{1}{2}$$. We now wish to calculate $$E(Y^2)$$.

$E(Y^2) = \frac{0^2 \times 125 + 1^2 \times 75 + 2^2 \times 15 + 3^2 \times 1}{216} = \frac{144}{216} = \frac{2}{3}.$

Therefore, $$Var(Y) = \frac{2}{3} - \left(\frac{1}{2}\right)^2 = \frac{5}{12}$$.

Note by Calvin Lin
3 years, 12 months ago

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$...$$ or $...$ to ensure proper formatting.
2 \times 3 $$2 \times 3$$
2^{34} $$2^{34}$$
a_{i-1} $$a_{i-1}$$
\frac{2}{3} $$\frac{2}{3}$$
\sqrt{2} $$\sqrt{2}$$
\sum_{i=1}^3 $$\sum_{i=1}^3$$
\sin \theta $$\sin \theta$$
\boxed{123} $$\boxed{123}$$

Sort by:

Why do you have to square the differences?

- 3 years, 10 months ago

We are interested in measuring how spread out the data is. Squaring allows us to emphasize large differences while reducing the impact of small differences.

Variance, is defined as the second central moment, which is why we take it as $$E[ (X - \mu)^2]$$. Skew, is the third central moment, in which we take cubes instead of squares, namely $$E[ ( X - \mu)^3 ]$$.

Staff - 3 years, 10 months ago

But those cubes won't always be positive....?

- 3 years, 10 months ago

Skew doesn't need to be a positive value. A negative skew will indicate that there (is likely to be ) a longer tail on the left.

Staff - 3 years, 10 months ago

But variance is always positive?

- 3 years, 10 months ago