3
$\begingroup$

I need to solve the following problem:

Given $n$ yes/no experiments, and a success probability $p$, at least how many successes $k$ can I expect (say, with a 'confidence' of $c=95\%$ or more)?

Another way to put it is: I want to be 95% sure to have at least $k$ successes. Everything is given, and I am interested in $k$.

As the Cumulative Distribution Function (CDF) for the Binomial Distribution is $$ F(k; n, p) = P(X \leq k) = I(1 - p; n - k, k + 1), $$ where $I(\cdot; \cdot, \cdot)$ denotes the regularized incomplete beta function, and I'm mostly interested in calculating the numerical outcome, the way I wanted to do it is to solve $$ P(X \geq k) = 1 - P(X \leq k - 1) = I(p; k, n - k + 1) = c $$ for $k$ using Maxima (although any other approach/tool would be good, too).

Doing some sanity checks with the CDF, though, I get unexpected results. For example, I would expect to get a probability value for

F(1; 100, .63)
= beta_incomplete_regularized(.37, 99, 2)

However, Maxima outputs:

1.898744430721408*10^-16*%i+1.014897496320844

Any comments/hints to this output, or to the approach in general? What other tools would be simple to use here?

$\endgroup$
2
  • $\begingroup$ For a discrete variable, "cumulative distribution function" is good terminology widely acceptable. In contrast "cumulative density function" divides the population. Many would think that discrete variables have probability mass functions rather than probability density functions. Everything depends on how you define density, but a diversion into measure theory can be avoided by using cumulative distribution function here. $\endgroup$
    – Nick Cox
    Aug 8, 2013 at 15:22
  • $\begingroup$ Closely related, but not (in my opinion) a duplicate $\endgroup$
    – Silverfish
    Oct 28, 2015 at 21:06

2 Answers 2

4
$\begingroup$

I used Mathematica to solve this:

The general rule to find k is

InverseCDF[BinomialDistribution[n, p], confidence interval] = k

Suppose you have $n=10$, $p=0.4$ and you want the value of $k$ at 95% confidence.

InverseCDF[BinomialDistribution[10, 0.4], 0.95]

You get answer 7.

$\endgroup$
1
  • $\begingroup$ If you do not have Mathematica, Excel has an inverse binomial CDF as well : =BINOM.INV(10,0.4,0.95) $\endgroup$
    – A.G.
    Dec 20, 2015 at 1:54
1
$\begingroup$

Found the solution:

As the CDF is $F(k, n, p) = 1 - F(n - k - 1, n, 1 - p)$ (wikipedia), solving for at-least-$k$-with-95%-confidence means to substract the 95%-quantile of $F(n - k, n, 1 - p) = 1 - F(k - 1, n, p)$ from $n$.

This way it also works in Maxima:

100 - quantile_binomial(.95,100,.37);
                                55

For example, with $n=100$ yes/no experiments, and a success probability $p=0.63$, I can be 95% sure to have at least $k=55$ successes.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.