The probability of a success is $0.81$. The probability of a failure is $0.19$. What's the average number of trials until we get both outcomes (a success and a failure)?
I started with E[X] = 2*2(0.81 * 0.19) + 3(0.81 * 0.81 * 0.19) + 3*(0.19 * 0.19 * 0.81) + ... I am not sure if I'm correct.
Average number of trials until we get $1$ success and $1$ failure
175 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 4 best solutions below
On
I would encode the problem as a Markov chain with the following state machine

where S is the starting state, A means that you have had only successes so far, B means that you have had only failures so far, and E is the goal state (one success and one failure). Then, you can find expressions for the Expected hitting times of the state E which will tell you the average number of jumps the chain needs before hitting state E.
On
Let's abbreviate $p = 0.81$, the probability of a success. If you are finished on the $n$th trial, that means either:
1) You have $n-1$ successes followed by a failure, which has probability $p^{n-1}(1 - p)$.
2) You have $n-1$ failures follows by a success, which has probability $(1 - p)^{n-1}p$.
So you must evaluate:
$$E = \sum_{n = 2}^{\infty}n[p^{n-1}(1 - p) + (1 - p)^{n-1}p]$$
You can use the sum:
$$\sum_{n = 1}^{\infty}nx^{n-1} = \frac{1}{(1 - x)^{2}}$$
Which is valid for $|x| < 1$.
On
First, a needed identity, to be used later . . .
For $-1 < x < 1$, let $f(x) = x^2 + x^3 + x^4+\cdots$.
Then $f'(x) = 2x + 3x^2 + 4x^3 + \cdots$.
But for $-1 < x < 1$, summing the geometric series, we have $f(x) = {\large{\frac{x^2}{1-x}}}$, hence $f'(x)={\large{\frac{x(2-x)}{(1-x)^2}}}$.
Thus, for $-1 < x < 1$, we have the identity $$2x + 3x^2 + 4x^3 + \cdots=\frac{x(2-x)}{(1-x)^2}\tag{1}$$
Returning to the problem at hand, let $p$ be the probability of success, and let $q=1-p$.
For $k \ge 2$, the probability that the experiment ends on the $k$-th flip is $$p^{k-1}q+q^{k-1}p$$ hence, the expected number of flips is \begin{align*} &\sum_{k=2}^\infty k(p^{k-1}q+q^{k-1}p)\\[4pt] &q\sum_{k=2}^\infty kp^{k-1}+p\sum_{k=2}^\infty kq^{k-1}\\[4pt] &q\left(\frac{p(2-p)}{(1-p)^2}\right)+p\left(\frac{q(2-q)}{(1-q)^2}\right)&&\text{[by $(1)$]}\\[4pt] &q\left(\frac{p(2-p)}{q^2}\right)+p\left(\frac{q(2-q)}{p^2}\right)\\[4pt] &\frac{p(2-p)}{q}+\frac{q(2-q)}{p}\\[4pt] \end{align*} Using the values $p={\large{\frac{81}{100}}},\;q={\large{\frac{19}{100}}}$, we get $$\frac{p(2-p)}{q}+\frac{q(2-q)}{p}=\frac{8461}{1539}\approx 5.497725796$$
Denote by $E_0$ the expected number of trials at the start, by $E_s$ the expected number of additional trials when you have seen $\geq1$ successes, but the game is not yet over, and similarly for $E_f$. Then we have the equations $$E_0=1+p_s E_s+p_f E_f,\quad E_s=1+p_sE_s,\quad E_f=1+p_f E_f\ .$$ Solving this system gives $$E_0=1+{p_s\over p_f}+{p_f\over p_s}=5.498\ .$$