# Expected number of throws when encountering a pokemon

I have a question about using geometric distribution to analyze a spefic issue of the Pokemon Go game. First let me describe the context.

When a player throws a ball to catch a pokemon, the success rate is a fixed number p. If the pokemon is not caught by the ball, the probability that it flees is f. If the pokemon does not flee, the player can throw the ball again, and each throw is an independant event. Assuming the player continues to throw balls until either the pokemon is caught or it flees, we would like to calcuatel the expected # of balls the player throws when a pokemon is encountered.

I will describe my derivation below, but my result is diffrenet from the well known web site Gamepress, so I'd like to confirm the right answer.

There are two conditions: when the player succesds to catch it, and when the pokemon eventually flees.

The probability of successfully catching the pokemon is:

$$p + (1-p)(1-f)p + [(1-p)(1-f)]^2p+...$$ $$= p\sum_{x=1}^\infty[(1-p)(1-f)]^{x-1}$$ $$= p\frac{1}{1-(1-p)(1-f)}$$ $$= \frac{p}{p+f-fp}$$

Similary, the probability that the pokemon flees is:

$$(1-p)f + (1-p)(1-f)(1-p)f + (1-p)[(1-f)(1-p)]^2f+...$$ $$= (1-p)f\sum_{x=1}^\infty[(1-p)(1-f)]^{x-1}$$ $$= (1-p)f\frac{1}{1-(1-p)(1-f)}$$ $$= \frac{(1-p)f}{p+f-fp}$$

The expected number of throws at the condition that the pokemon is caught is:

$$= p\sum_{x=1}^\infty(x[(1-p)(1-f)]^{x-1})$$ $$= p\frac{d}{dZ}\sum_{x=1}^\infty[Z^x], Z=(1-p)(1-f)$$ $$= p\frac{d}{dZ}\frac{Z}{1-Z}$$ $$= \frac{p}{(1-Z)^2}$$ $$= \frac{p}{(p+f-fp)^2}$$

The expected number of throws when the pokemon flees is:

$$= f(1-p)\sum_{x=1}^\infty(x[(1-p)(1-f)]^{x-1})$$ $$= f(1-p)\frac{d}{dZ}\sum_{x=1}^\infty[Z^x], Z=(1-p)(1-f)$$ $$= f(1-p)\frac{d}{dZ}\frac{Z}{1-Z}$$ $$= \frac{f(1-p)}{(1-Z)^2}$$ $$= \frac{f(1-p)}{(p+f-fp)^2}$$

The expected number of throws, without knowing whether the pokemon is caught is The probability of successfully catching the pokemon x The expected number of throws at the condition that the pokemon is caught + the probability that the pokemon flees x The expected number of throws when the pokemon flees:

$$\frac{p}{p+f-fp}\times\frac{p}{(p+f-fp)^2} + \frac{(1-p)f}{p+f-fp}\times\frac{f(1-p)}{(p+f-fp)^2}$$

$$= \frac{p^2+f^2(1-p)^2}{(p+f-fp)^3}$$

Gamepress does not provide the equation (https://pokemongo.gamepress.gg/catchcalc#/), but it appears it is using the same formula described here:

Which is $$\frac{1}{p+f-fp}$$

and appears to be

$$\frac{p}{(p+f-fp)^2} +\frac{f(1-p)}{(p+f-fp)^2}$$

Therefore my question is, which formula is correct, and why? Thanks!

Let's define a variable $$C = \begin{cases} 1 \qquad \text{ if pokemon is caught} \\ 0 \qquad \text{ otherwise}\\ \end{cases}$$ and let $B$ be the number of balls thrown. The error in your solution is that you have attempted to apply the conditional expectation formula, $$E(B) = E(B | C=0) \; \Pr(C=0) + E(B| C=1) \; \Pr(C=1)$$ but you have computed $$\sum_x x \; \Pr(B=x, C=0)$$ instead of $$E(B|C=0) = \sum_x x \; \frac{\Pr(B=x, C=0)}{\Pr(C=0)}$$ and similarly for the $C=1$ case.
Here is a derivation of the Gamepress formula. On the first encounter with the pokemon, there are three possibilities: with probability $p$, the pokemon is caught; or with probability $(1-p)f$, the pokemon is missed and flees; or with probability $(1-p)(1-f)$, the pokemon is missed and stays. In the case where the pokemon is missed and stays, we are back in the original starting state, except that we have expended one ball. So if we let $E$ be the expected number of balls thrown, $$E = p + (1-p) f + (1-p)(1-f)(E+1)$$ Solving this equation for $E$, we find $$E = \frac{1}{p + f - fp}$$ which is the Gamepress formula.