# Finding the mean and variance of the number of successes of a sequence of independent trials.

In a sequence of $n$ independent trials the probability of a success at the $i^{\mathrm{th}}$ trial is $p_i$. Find the mean and variance of the total number of successes.

My problem is should I let $X_i$ be the event that the $i^{\mathrm{th}}$ is a success or that $i$ trials have been successful, where $X=X_1+X_2+\cdots +X_n$.

• Your idea is a useful one. We define the random variable $X_i$ by $X_i=1$ if we have a success on the $i$-th trial, and by $X_i=0$ otherwise. Then the number $X$ of successes is given by $X=X_1+\cdots+X_n$. Now $E(X)$ is immediate by the linearity of expectation. For the variance, it will be a good idea to expand $(X_1+\cdots+X_n)^2$. Feb 24, 2015 at 17:14
• thank you, I think I can see where to go from here! Feb 24, 2015 at 17:36
• You are welcome. I thought it best to outline things only, so that you could do the rest. Note that there is a simpler way to get at the variance, since we are dealing with an independent sum. Feb 24, 2015 at 17:40
• Hmm, I can't find a way to tidy up the (X1+...+Xn)^2 expression. I tried to use the fact the events are independent therefore E(XY)=E(X)E(Y). I am not sure I know a simpler formula for the variance. Feb 24, 2015 at 18:00
• The simple way is to use $\text{Var}(X)=\sum \text{Var}(X_i)$. An easy computation (or standard fact) shows that $\text{Var}(X_i)=p_i(1-p_i)$. The harder way is to expand. The mean of $X_i^2$ is $p_i$ since $X_i^2=X_i$. The cross terms have expectation $2\sum_{i\lt j}p_ip_j$. So the expectation of $X^2$ is $\sum p_i+2\sum_{i\lt j}p_ip_j$. Subtract $(E(X))^2$. We get a messy expression that simplifies a lot. Feb 24, 2015 at 18:12

Recall that for independent random variables $X_i$: $$\mathbb E\left[\sum_{i=1}^n X_i\right] = \sum_{i=1}^n\mathbb E[X_i]$$ and $$\operatorname{Var}\left(\sum_{i=1}^n X_i\right) = \sum_{i=1}^n \operatorname{Var}(X_i).$$ Applying these with $\mathbb E[X_i]=p_i$ and $\operatorname{Var}(X_i)=p_i(1-p_i)$ we get that the mean and variance of the sum are $$\sum_{i=1}^n p_i$$ and $$\sum_{i=1}^n p_i(1-p_i),$$ respectively.