# Formula for the Negative binomial inverse cumulative function

For example, how many times (N) do I need to flip a coin (p=0.5) to have a P=90% probability of having observed 20 heads. I empirically found that I need N=20+28=48. Is it correct?

Is there an explicit formula for the Negative binomial inverse cumulative function?

-
If you have MATLAB, see mathworks.com/help/toolbox/stats/nbininv.html –  Shai Covo Jan 26 '11 at 1:23
I use Maple (statevalf,idcdf,negativebinomial) but I would like to know if there is an explicit formula. –  Jean-Pierre Jan 26 '11 at 1:47
We know that $F(k) = P(X \leq k) = 1-I_{p}(k+1,r)$ where $I_{p}(k+1,r)$ is the incomplete beta function. So $0.9 = 1-I_{0.5}(k+1,r)$. From this, I believe you have enough information to get $k$ and $r$ and hence $n$.