# Expected value and variance of number of successes minus number of failures

This is one of my friends homework question. I tried to solve it and explain to him but I couldn't solve it. The question is simple.

Let $X_n = (\text{# of successes}) - (\text{# of failures})$

in $n$ Bernoulli trials with possibility of success = $p$, and possibility of failure = $(1-p)$ for each of the Bernoulli trials. Find $E[X_n]$ and $Var[X_n]$.

My attempt to find the PMF of $X_n$ is the following:

$f(x)= \begin{cases} p^n, & \text{if } x=n \\ p^{n-1}(1-p)^1 \binom{n}{n-1}, & \text{if } x=n-2 \\ p^{n-2}(1-p)^2 \binom{n}{n-2}, & \text{if } x=n-4 \\ \vdots & \vdots \\ (1-p)^n, & \text{if } x=-n \\ 0 & \text{otherwise} \end{cases}$

More compactly,

$f(n-i)= \begin{cases} p^{(n-\frac{i}{2})} (1-p)^{(\frac{i}{2})}\binom{n}{n-\frac{i}{2}}, & \text{if } 0 \leq i \leq 2n \text{ and } i \% 2 = 0 \\ 0 & \text{otherwise} \end{cases}$

And using this PMF, expected value will be:

\begin{align} E[x] &= \sum_{i} i f(i) \\ &= \sum_{i \in {0 \leq i \leq 2n \text{ and } i \% 2 = 0}} (n-i) p^{(n-\frac{i}{2})} (1-p)^{(\frac{i}{2})}\binom{n}{n-\frac{i}{2}} \end{align}

This is where I got stuck. I feel like there is a simpler way to solve this.

Any ideas?

• There is a direct relationship between the number of successes and the number of failures given a fixed $n$ trials. The sum of failures and successes equals $n$. – StatsPlease Jan 25 '17 at 5:19

Notice that $\#failures = n - \#successes$, thus $X_n = 2\, \#successes - n$. Since we know that $Y_n := \#successes \sim Binomial(n, p)$, we have that $$E[X_n] = 2 \,E[Y_n] - n = 2np - n$$ and $$Var(X_n) = 4 \,Var(Y_n) = 4np(1-p).$$