Waiting time to observe both Bernoulli outcomes (source code)

= Waiting time to observe both Bernoulli outcomes
{title2=$EN=\frac1{p(1-p)}-1$}

In independent trials with two outcomes of <probabilities> $p$ and $q=1-p$, let $N$ include the first trial and the trial that first completes the pair. Conditional on the first outcome, $N-1$ has a <geometric distribution> of parameter $q$ or $p$, with mixture weights $p,q$. The <law of total expectation> and <law of total variance> give
$$
EN=1+\frac pq+\frac qp=\frac1{pq}-1,\qquad
\operatorname{Var}N=\frac{p^2}{q^2}+\frac{q^2}{p^2}+\frac{(p-q)^2}{pq}
=\frac1{p^2q^2}-\frac3{pq}-2.
$$
The final term in the unsimplified variance is the <variance> of the two conditional means; omitting it is incorrect unless $p=q$. Both outcomes must have positive <probability> for these finite formulas.