Finding the inverse of the binomial cumulative distribution function I am trying to find a mathematical solution to the inverse of the binomial cumulative distrbution function, essentially mathematically representing the Excel function BINOM.INV.
Given a number of trials $n$, the probability of success $p$, and the cumulative area of the binomial distribution $\alpha$, I need to find a value $x$ such that
$$
\alpha = \sum_{k\ =\ 0}^x\binom{n}{k}\ p^k\;\left(1-p\right)^{\ n-k}
$$
So that if
$$
\begin{align}
\alpha &= 0.7 \\
p &= 0.3 \\
n &= 100 \\
\end{align}
$$
$x$ would be equal to $32$, replicating the following Excel formula:
32 = BINOM.INV(100, 0.3, 0.7)

How could I achieve such a value mathematically, not using Excel?
 A: The statistical term for what you are looking for is the so called quantile function. For a random variable with distribution function $F$ it is defined as follows:
$$Q(p)\,=\,\inf\left\{ x\in \mathbb{R} : p \le F(x) \right\} $$
For continuous, strictly increasing distribution functions, this is equivalent to:
$$Q(p) = F^{-1}(p)$$
The modification with $\inf\{\cdot\}$ is required for cases as the one you describe, where you have a non-bijective distribution functions. This is the case for discrete distribution functions such as the binomial distribution.
Notice that you wrote that you need to find $x$ such that:
$$\alpha = \sum_{k\ =\ 0}^x\binom{n}{k}\ p^k\;\left(1-p\right)^{\ n-k}$$
In fact such $x$ does not necessarily exist. Instead you are looking for the smallest $x$ such that:
$$\alpha \leq \sum_{k\ =\ 0}^x\binom{n}{k}\ p^k\;\left(1-p\right)^{\ n-k}=:B(n,p,x)$$
A very easy (naive) way to find this value on your own (for discrete distributions as the binomial) is to calculate the above right hand side for increasing value of $x$ until you find the first $x$ satisfying your condition:
With your values for $\alpha, n ,p$ we get:
$$
\begin{aligned}
B(100,0.3, 0) &\approx 3.2\cdot10^{-16} \\
B(100,0.3, 1) &\approx 1.4\cdot10^{-14} \\
&\vdots \\
B(100,0.3, 30) &\approx 0.549 \\
B(100,0.3, 31) &\approx 0.633 \\
B(100,0.3, 32) &\approx 0.711 \\
B(100,0.3, 33) &\approx 0.779 \\
\end{aligned}
$$
As you can see, the first $x$ for which $B(100,0.3,x)$ exceeds $\alpha=0.7$ is $x=32$ which is also the output of the Excel formula.
