[Math] Variance of n Bernoulli Trials

discrete mathematicsprobability

Count the variance of n Bernoulli trials with each probability of success is p.

Let random variable $X_i$ be
$1$ if trial is success, or
$0$ if trial fails.

Then expected value $E(X_i) = 1 \times p + 0 \times (1 – p) = p$.
By linearity of expectation $E(X) = p_1 + p_2 + … + p_n = np$.

To count the variance, I use this formula $V(X) = E(X^2) – E(X)^2$.

where $E(X_i^2) = 1^2 \times p + 0^2 \times (1 – p) = p$
then, $E(X^2) = p_1 + p_2 + … + p_n = np$.

So, I got variance $V(X) = np – (np)^2 = np(1 – np)$.

But in wiki,
it says that the correct variance is $np(1 – p)$.

Where did I do wrong?
Thanks a lot for the help.

Best Answer

The variance of $n$ independent things is the sum of their variances, so $$\text{Var}(X)=\sum_i\text{Var}(X_i)=\sum_iE(X_i^2)-E(X_i)^2$$ Note that your proposed equality $$\text{Var}(X)= E(X^2)-E(X)^2=\sum_iE(X_i^2)- \left(\sum_iE(X_i)\right)^2$$ does not satisfy this, as here the squaring is done after the summing, so two different terms $E(X_i)$ and $E(X_j)$ will multiply, so the independence is lost.