search
Search
Unlock 100+ guides
search toc
close
account_circle
Profile
exit_to_app
Sign out
search
keyboard_voice
close
Searching Tips
Search for a recipe:
"Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview Doc Search Code Search Beta SORRY NOTHING FOUND!
mic
Start speaking... Voice search is only supported in Safari and Chrome.
Shrink
Navigate to

# Properties of variance

schedule Aug 12, 2023
Last updated
local_offer
Tags
mode_heat
Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!

If you are not familiar with the concept of variance, please consult our guide on variance first.

Just as we did in the section of expected values, we will prove the properties of variance for the case of discrete random variables. These properties also hold for the continuous random variables, and their proofs are analogous to the discrete case.

Theorem.

# Computational form of variance

The variance of a random variable $X$ can also be computed by:

$$\mathbb{V}(X)=\mathbb{E}(X^2)-\big[\mathbb{E}(X)\big]^2$$

We typically use this equation instead of the definition to compute the variance of $X$.

Proof. We begin with the definition of variance:

\begin{align*} \mathbb{V}(X)&=\mathbb{E}\big[(X-\mu)^2\big]\\ &=\sum_x(x-\mu)^2\cdot{p(x)}\\ &=\sum_x(x^2-2\mu{x}+\mu^2)\cdot{p(x)}\\ &=\sum_x\Big(x^2\cdot{p(x)}-2\mu{x}\cdot{p(x)}+\mu^2\cdot{p(x)}\Big)\\ &=\sum_x\Big(x^2\cdot{p(x)}\Big)-2\mu\sum_x\Big(x\cdot{p(x)}\Big)+\mu^2\sum_xp(x)\\ &=\mathbb{E}(X^2)-2\mu\cdot\mathbb{E}(X)+\mu^2\\ &=\mathbb{E}(X^2)-2\mu^2+\mu^2\\ &=\mathbb{E}(X^2)-\mu^2\\ &=\mathbb{E}(X^2)-[\mathbb{E}(X)]^2 \end{align*}

This completes the proof.

Theorem.

# Variance of aX+b where a and b are constants

Let $X$ be a random variable. If $a$ and $b$ are constants, then:

$$\mathbb{V}(aX+b)=a^2\cdot{\mathbb{V}(X)}$$

Proof. To compute the variance of $aX+b$, we first need to compute the mean value of $aX+b$. To avoid confusion, we will denote the mean of $X$ as $\mu_X$ and the mean of $aX+b$ as $\mu_{aX+b}$. The mean of $aX+b$ is as follows:

\begin{align*} \mu_{aX+b}&=\mathbb{E}(aX+b)\\ &=a\cdot{\mathbb{E}(X)}+b\\ &=a\cdot{\mu_X}+b\\ \end{align*}

Now, use the definition of variance:

\begin{align*} \mathbb{V}(aX+b)&= \mathbb{E}\big[(aX+b-\mu_{aX+b})^2\big]\\ &=\mathbb{E}\big[(aX+b-(a\mu_X+b))^2\big]\\ &=\mathbb{E}\big[(aX-a\mu_X)^2\big]\\ &=\mathbb{E}\big[(a(X-\mu_X))^2\big]\\ &=\mathbb{E}\big[a^2(X-\mu_X)^2\big]\\ &=a^2\cdot\mathbb{E}[(X-\mu_X)^2\big]\\ &=a^2\cdot\mathbb{V}(X)\\ \end{align*}

This completes the proof.

Theorem.

# Variance of sum of two random variables

The variance of the sum of two random variables $X$ and $Y$ is:

\begin{align*} \mathbb{V}(X+Y)=\mathbb{V}(X)+\mathbb{V}(Y)+2\cdot{\mathrm{cov}(X,Y)}\\ \end{align*}

Where $\text{cov}(X,Y)$ is the covariance of $X$ and $Y$.

Proof. Let the mean of random variables $X$ and $Y$ be $\mu_X$ and $\mu_Y$, respectively. We also denote the mean of $X+Y$ as $\mu_{X+Y}$. From the definition of variance:

\begin{align*} \mathbb{V}(X+Y) &=\mathbb{E}\big[(X+Y-\mu_{X+Y})^2\big]\\ &=\mathbb{E}\big[(X+Y-\mathbb{E}(X+Y))^2\big]\\ &=\mathbb{E}\big[(X+Y-\mathbb{E}(X)-\mathbb{E}(Y))^2\big]\\ &=\mathbb{E}\big[(X+Y-\mu_X-\mu_Y)^2\big]\\ &=\mathbb{E}\big[\big((X-\mu_X)+(Y-\mu_Y)\big)^2\big]\\ &=\mathbb{E}\big[(X-\mu_X)^2+(Y-\mu_Y)^2+2(X-\mu_X)(Y-\mu_Y)\big]\\ &=\mathbb{E}\big[(X-\mu_X)^2\big] +\mathbb{E}\big[(Y-\mu_Y)^2\big] +2\mathbb{E}\big[(X-\mu_X)(Y-\mu_Y)\big]\\ &=\mathbb{V}(X)+\mathbb{V}(Y)+2\cdot\mathrm{cov}(X,Y) \end{align*}

This completes the proof.

Theorem.

# Variance of the difference of two random variables

The variance of the difference of two random variables $X$ and $Y$ is:

$$\mathbb{V}(X-Y)=\mathbb{V}(X)+\mathbb{V}(Y)-2\cdot{\mathrm{cov}(X,Y)}\\$$

Where $\text{cov}(X,Y)$ is the covariance of $X$ and $Y$.

Proof. We know from theoremlink that:

\begin{align*} \mathbb{V}(X+Y)=\mathbb{V}(X)+\mathbb{V}(Y)+2\cdot{\mathrm{cov}(X,Y)}\\ \end{align*}

Setting $Y=-Y'$ gives:

\begin{align*} \mathbb{V}(X-Y') &=\mathbb{V}(X)+\mathbb{V}(-Y')+2\cdot{\mathrm{cov}(X,-Y')}\\ &=\mathbb{V}(X)+\mathbb{V}(Y')-2\cdot{\mathrm{cov}(X,Y')}\\ \end{align*}

For the second equality, we used theoremlink and theorem TODO.

Theorem.

# Variance of sum of two independent variables

The variance of a sum of two independent random variables $X$ and $Y$ is:

$$\mathbb{V}(X+Y)=\mathbb{V}(X)+\mathbb{V}(Y)$$

Proof. We know from theoremlink that:

\begin{align*} \mathbb{V}(X+Y) =\mathbb{V}(X)+\mathbb{V}(Y)+2\cdot{\mathrm{cov}(X,Y)}\\ \end{align*}

If $X$ and $Y$ are independent, then their covariance is zero. This completes the proof.

Theorem.

# Interchanging the summation sign and variance

If $X_1,X_2,\cdots,X_n$ are independent random variables, then:

$$\sum_{i=1}^{n}\mathbb{V}(X_i) = \mathbb{V}\Big(\sum_{i=1}^{n}X_i\Big)$$

Note that this is only true when the random variables are independent.

Proof. Let's start from the left-hand side:

$$\begin{equation}\label{eq:xHVLlnGdf6OA8hdl19R} \sum^n_{i=1}\mathbb{V}(X_i) =\mathbb{V}(X_1)+\mathbb{V}(X_2)+\cdots+\mathbb{V}(X_n) \end{equation}$$

From theoremlink, we know that $\mathbb{V}(X)+\mathbb{V}(Y)=\mathbb{V}(X+Y)$ if $X$ and $Y$ are independent random variables. Since $X_1,X_2,\cdots,X_n$ are all independent, then \eqref{eq:xHVLlnGdf6OA8hdl19R} becomes:

\begin{align*} \sum^n_{i=1}\mathbb{V}(X_i) &=\mathbb{V}(X_1+X_2+\cdots+X_n)\\ &=\mathbb{V}\Big(\sum^n_{i=1}X_i\Big) \end{align*}

This completes the proof.

Theorem.

# Law of total variance

The law of total variance states that:

$$\mathbb{V}(X) =\mathbb{E}\big[\mathbb{V}(X|Y)\big] +\mathbb{V}\big[\mathbb{E}(X|Y)\big]$$

Here, $\mathbb{E}\big[\mathbb{V}(X|Y)\big]$ is referred to as the within-group variation, while $\mathbb{V}\big[\mathbb{E}(X|Y)\big]$ is referred to as the between-group variation.

Proof. Let us color-code the law of total variance:

$$\begin{equation}\label{eq:hxeXJ27Ezx8yJHNtkdd} \mathbb{V}(X) =\mathbb{E} \big[{\color{green}\mathbb{V}(X|Y)}\big]+ {\color{red}\mathbb{V}\big[\mathbb{E}(X|Y)\big]} \end{equation}$$

$${\color{green}\mathbb{V}(X|Y)}= \mathbb{E}(X^2|Y)-\big[\mathbb{E}(X|Y)\big]^2\\$$

Taking the expected value on both sides:

$$\mathbb{E}\big[{\color{green}\mathbb{V}(X|Y)}\big] ={\color{purple}\mathbb{E}\big[\mathbb{E}(X^2|Y)\big]} -\mathbb{E}\big[\mathbb{E}(X|Y)^2\big]$$

From the law of total expectation TODO, we know that ${\color{purple}\mathbb{E}\big[\mathbb{E}(X^2|Y)\big]} =\mathbb{E}(X^2)$:

$$\begin{equation}\label{eq:Keng91E84H2xMJ4cEes} \mathbb{E}\big[{\color{green}\mathbb{V}(X|Y)}\big]= \mathbb{E}(X^2)-\mathbb{E}\big[\mathbb{E}(X|Y)^2\big] \end{equation}$$

We then move on to the red term in \eqref{eq:hxeXJ27Ezx8yJHNtkdd}. From theoremlink, we have that:

$${\color{red}\mathbb{V}\big[\mathbb{E}(X|Y)\big]} =\mathbb{E}\big[\big(\mathbb{E}(X|Y)\big)^2\big]- {\color{orange}\big[\mathbb{E}\big(\mathbb{E}(X|Y)\big)\big]^2}$$

Again, from the law of total expectation TODO, we have that ${\color{orange}\big[\mathbb{E}\big(\mathbb{E}(X|Y)\big)\big]^2} = \big[\mathbb{E}(X)\big]^2$:

$$\begin{equation}\label{eq:GNQl9RdOFbD0Abu3OG6} {\color{red}\mathbb{V}\big[\mathbb{E}(X|Y)\big]}= \mathbb{E}\big[\big(\mathbb{E}(X|Y)\big)^2\big]-\big[\mathbb{E}(X)\big]^2 \end{equation}$$

Taking the sum of \eqref{eq:Keng91E84H2xMJ4cEes} and \eqref{eq:GNQl9RdOFbD0Abu3OG6} yields:

\begin{align*} \mathbb{E}\big[{\color{green}\mathbb{V}(X|Y)}\big] +{\color{red}\mathbb{V}\big[\mathbb{E}(X|Y)\big]} &=\mathbb{E}(X^2)-\mathbb{E}\big[\mathbb{E}(X|Y)^2\big]+\mathbb{E}\big[\big(\mathbb{E}(X|Y)\big)^2\big]-\big[\mathbb{E}(X)\big]^2\\ &=\mathbb{E}(X^2)-\big[\mathbb{E}(X)\big]^2\\ &=\mathbb{V}(X) \end{align*}

This completes the proof.

thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!