# Geometric Distribution: The finite Case

Suppose I flip coins until either the first coin comes down head or I have flipped 10 coins, all of which came down tail. How many times do I flip coins in expectation?

Is there a closed form expression for the expected number of trials for arbitrary success probabilities and upper bound on the number of trials?

In the example, the distribution of the number of trials approaches a geometric distribution with mean 2 when I continue flipping coins longer and longer. For the example, the expected number of trials is $\frac{509}{256}$, which is, unsurprisingly, smaller than $2$.

-
$\sum_{n=1}^N p(1-p)^{n-1}$ with $p$ being the probability of head coming up and $N$ the number of rounds. – Michael Greinecker Apr 8 '12 at 0:05
Thank you. Yes, that is the correct explicit summation. Now: Is there a way to simplify the formula, without involving the summation? Ideally, is there a reference? – Stephan Apr 8 '12 at 0:16

If you flip a coin with success probability $p$ until the first success, you expect $1/p$ trials. The probability for not getting a success in $n$ trials is $(1-p)^n$. If you stop after $n$ trials, you reduce the expected number of trials by $1/p$ with probability $(1-p)^n$. Thus the expected number of trials becomes $(1-(1-p)^n)/p$.
@Stephan: Then perhaps you could share your Matlab code? I don't see where my argument could go wrong, and $509/256=2-3/256$ doesn't feel right; I don't see how the $3$ could arise. Also, you could try some easier examples first, with $n=1,2,3$ -- as far as I can tell, my answer is correct for those, and it seems very unlikely that it could start going wrong only for higher $n$. – joriki Apr 8 '12 at 0:32