# Variance

 Definition (variance) The variance of a random variable ${\displaystyle X}$ is defined as {\displaystyle {\begin{aligned}\mathbf {Var} [X]=\mathbf {E} \left[(X-\mathbf {E} [X])^{2}\right]=\mathbf {E} \left[X^{2}\right]-(\mathbf {E} [X])^{2}.\end{aligned}}} The standard deviation of random variable ${\displaystyle X}$ is ${\displaystyle \delta [X]={\sqrt {\mathbf {Var} [X]}}.}$

We have seen that due to the linearity of expectations, the expectation of the sum of variable is the sum of the expectations of the variables. It is natural to ask whether this is true for variances. We find that the variance of sum has an extra term called covariance.

 Definition (covariance) The covariance of two random variables ${\displaystyle X}$ and ${\displaystyle Y}$ is {\displaystyle {\begin{aligned}\mathbf {Cov} (X,Y)=\mathbf {E} \left[(X-\mathbf {E} [X])(Y-\mathbf {E} [Y])\right].\end{aligned}}}

We have the following theorem for the variance of sum.

 Theorem For any two random variables ${\displaystyle X}$ and ${\displaystyle Y}$, {\displaystyle {\begin{aligned}\mathbf {Var} [X+Y]=\mathbf {Var} [X]+\mathbf {Var} [Y]+2\mathbf {Cov} (X,Y).\end{aligned}}} Generally, for any random variables ${\displaystyle X_{1},X_{2},\ldots ,X_{n}}$, {\displaystyle {\begin{aligned}\mathbf {Var} \left[\sum _{i=1}^{n}X_{i}\right]=\sum _{i=1}^{n}\mathbf {Var} [X_{i}]+\sum _{i\neq j}\mathbf {Cov} (X_{i},X_{j}).\end{aligned}}}
Proof.
 The equation for two variables is directly due to the definition of variance and covariance. The equation for ${\displaystyle n}$ variables can be deduced from the equation for two variables.
${\displaystyle \square }$

We will see that when random variables are independent, the variance of sum is equal to the sum of variances. To prove this, we first establish a very useful result regarding the expectation of multiplicity.

 Theorem For any two independent random variables ${\displaystyle X}$ and ${\displaystyle Y}$, {\displaystyle {\begin{aligned}\mathbf {E} [X\cdot Y]=\mathbf {E} [X]\cdot \mathbf {E} [Y].\end{aligned}}}
Proof.
 {\displaystyle {\begin{aligned}\mathbf {E} [X\cdot Y]&=\sum _{x,y}xy\Pr[X=x\wedge Y=y]\\&=\sum _{x,y}xy\Pr[X=x]\Pr[Y=y]\\&=\sum _{x}x\Pr[X=x]\sum _{y}y\Pr[Y=y]\\&=\mathbf {E} [X]\cdot \mathbf {E} [Y].\end{aligned}}}
${\displaystyle \square }$

With the above theorem, we can show that the covariance of two independent variables is always zero.

 Theorem For any two independent random variables ${\displaystyle X}$ and ${\displaystyle Y}$, {\displaystyle {\begin{aligned}\mathbf {Cov} (X,Y)=0.\end{aligned}}}
Proof.
 {\displaystyle {\begin{aligned}\mathbf {Cov} (X,Y)&=\mathbf {E} \left[(X-\mathbf {E} [X])(Y-\mathbf {E} [Y])\right]\\&=\mathbf {E} \left[X-\mathbf {E} [X]\right]\mathbf {E} \left[Y-\mathbf {E} [Y]\right]&\qquad ({\mbox{Independence}})\\&=0.\end{aligned}}}
${\displaystyle \square }$

We then have the following theorem for the variance of the sum of pairwise independent random variables.

 Theorem For pairwise independent random variables ${\displaystyle X_{1},X_{2},\ldots ,X_{n}}$, {\displaystyle {\begin{aligned}\mathbf {Var} \left[\sum _{i=1}^{n}X_{i}\right]=\sum _{i=1}^{n}\mathbf {Var} [X_{i}].\end{aligned}}}
Remark
The theorem holds for pairwise independent random variables, a much weaker independence requirement than the mutual independence. This makes the variance-based probability tools work even for weakly random cases. We will see what it exactly means in the future lectures.

## Variance of binomial distribution

For a Bernoulli trial with parameter ${\displaystyle p}$.

${\displaystyle X={\begin{cases}1&{\mbox{with probability }}p\\0&{\mbox{with probability }}1-p\end{cases}}}$

The variance is

${\displaystyle \mathbf {Var} [X]=\mathbf {E} [X^{2}]-(\mathbf {E} [X])^{2}=\mathbf {E} [X]-(\mathbf {E} [X])^{2}=p-p^{2}=p(1-p).}$

Let ${\displaystyle Y}$ be a binomial random variable with parameter ${\displaystyle n}$ and ${\displaystyle p}$, i.e. ${\displaystyle Y=\sum _{i=1}^{n}Y_{i}}$, where ${\displaystyle Y_{i}}$'s are i.i.d. Bernoulli trials with parameter ${\displaystyle p}$. The variance is

{\displaystyle {\begin{aligned}\mathbf {Var} [Y]&=\mathbf {Var} \left[\sum _{i=1}^{n}Y_{i}\right]\\&=\sum _{i=1}^{n}\mathbf {Var} \left[Y_{i}\right]&\qquad ({\mbox{Independence}})\\&=\sum _{i=1}^{n}p(1-p)&\qquad ({\mbox{Bernoulli}})\\&=p(1-p)n.\end{aligned}}}

# Chebyshev's inequality

With the information of the expectation and variance of a random variable, one can derive a stronger tail bound known as Chebyshev's Inequality.

 Theorem (Chebyshev's Inequality) For any ${\displaystyle t>0}$, {\displaystyle {\begin{aligned}\Pr \left[|X-\mathbf {E} [X]|\geq t\right]\leq {\frac {\mathbf {Var} [X]}{t^{2}}}.\end{aligned}}}
Proof.
 Observe that ${\displaystyle \Pr[|X-\mathbf {E} [X]|\geq t]=\Pr[(X-\mathbf {E} [X])^{2}\geq t^{2}].}$ Since ${\displaystyle (X-\mathbf {E} [X])^{2}}$ is a nonnegative random variable, we can apply Markov's inequality, such that ${\displaystyle \Pr[(X-\mathbf {E} [X])^{2}\geq t^{2}]\leq {\frac {\mathbf {E} [(X-\mathbf {E} [X])^{2}]}{t^{2}}}={\frac {\mathbf {Var} [X]}{t^{2}}}.}$
${\displaystyle \square }$