# Probability that the probability for a binomial distribution is below a certain value

This is a slightly odd problem I ran across recently. Assuming a population of size $N$ following a binomial distribution with unknown $p$, how many different samples must be taken from the population to say that $P[p<\phi]>\alpha$, assuming all the samples taken turn out to be failures?

My approach was to state that the probability of $p=x$ given $n$ failures is $$P[p=x|n] \propto (1-x)^n$$

Normalizing this so that $\int_0^1 P[p=x|n]\ dx=1$ gives $$P[p=x|n] = (n+1)(1-x)^n$$

The probability that $p<\phi$ is then easy to calculate as $$P[p<\phi|n] = \int_0^\phi (n+1)(1-x)^n\ dx = 1 - (1 - \phi)^{n + 1}$$

And finally solve the inequality $P[p<\phi|n]>\alpha$ $$1 - (1 - \phi)^{n+1} > \alpha \ \Rightarrow\ n > \frac{\ln 1 - \alpha}{\ln 1 - \phi} - 1$$

Now, my first question regarding this is whether my approach is correct or not.

Secondly, is there an intuitive way to explain/understand the equations above? Above I solved it only mathematically, but I'm really more interested in the why than the how.

For example, $1-(1-\phi)^{n+1}$ above, given $n$ failures, reads to me like the probability that the next sample taken is not a failure. But I see no connection between that and the left hand side $P[p<\phi|n]$.

-
A logical flaw silently occurs in the third equation. In the first two, $x$ is a random variable and $p$ is a parameter--it's just a number (albeit "unknown": but lack of knowledge does not make a quantity into a random variable!). The left hand side of the third equation, $P[p\lt\phi|n]$, is nonsense, because it references no random variables. To make sense of it, either $p$ or $\phi$ must be considered a random variable and, in order to make any progress, something has to be assumed about their distributions. –  whuber Sep 18 '12 at 20:58
@whuber I intended $p$ to be a random variable in the first two as well. To me $x$ is just a syntactic entity to express the equation more clearly. –  Anton Sep 18 '12 at 21:17
I see: at the outset you are asserting that the probability of $p$, conditional on the random variable $n$, is $(1-x)^n$. But where does that come from? –  whuber Sep 18 '12 at 21:30
I'm not sure what you mean, but I justified it as being the likelihood of $p$ in this case. –  Anton Sep 18 '12 at 21:45
Taking a (normalized) likelihood to be a probability works mathematically but reflects a conceptual mistake. The answers pointing you towards a Bayesian analysis suggest one direction to go in, but please make sure you understand why this is necessary and why your original calculations are not valid. –  whuber Sep 18 '12 at 22:42

You are not correct in the way that in the frequentist framework parameters (in your case probability\proportion) are NOT a random variable. However, if you assume Bayesian framework, you can safely work with parameters as random variables and to obtain probabilities that some parameters exceeds some value. You have your sampling distribution $$X|p,N \sim B(N,p)$$ Assume that you observed sample is $X_{1},...,X_{t}$. Then, the likelihood function is proportional to $$p^{r}(1-p)^{N-r},$$ where $r= \Sigma X_{k}$. Now you need prior distribution on the proportion parameter. The usual choise in this problem is to use beta distribution $B(\alpha, \beta)$. Then you posterior (due to the conjugacy property) will also be a beta distribution with updated parameters $B(\alpha +r, \beta +N-r)$ or $$p|X,N \sim B(\alpha +r, \beta +N-r)$$ Now you can calculate the probabilities that you want, though it is not straightforward, since it requires to calculate incomplete Beta function. Another aspect is that I dont see any way how to calculate the number of experiments, since all statistical information colapses to one sum $r$.

-
Wait a minute... I'm (perhaps obviously) not good with Bayesian statistics... but assuming a uniform prior distribution ($\alpha$=$\beta$=1 if I'm not mistaken) doesn't this work out to my solution? –  Anton Sep 18 '12 at 11:53
No, it does not. The posterior distribution is still bet distribution, but with slightly different parameters: $B(r,N-r)$ –  Tomas Sep 18 '12 at 12:13
Sorry, should be $B(r+1,N-r+1)$ –  Tomas Sep 18 '12 at 12:33
But this is done under the assumption all $X_k$ turn out to be zero, making $r=0$. Wouldn't that make the Beta distribution in question work out to $(N+1)(1 - x)^{N+1}$? –  Anton Sep 18 '12 at 12:37
What do you mean by "assumption all $X_{k}$ turn out to be zero"? Why would you make such assumption? Also, you might consider looking at this article, which (at first sight) gives some attention to your problem in frequentist way. ipnpr.jpl.nasa.gov/progress_report2/42-26/26T.PDF See section IV –  Tomas Sep 18 '12 at 13:48
The likelihood function is L(p)=(1-p)$^n$,.
ln[L(p)]= n ln(1-p) d/dp{ln[L(p)]} = -n/(1-p). -ln[l(p)] s maximum at p=0. If p=0 is not an acceptable answer because you know that p>0 and must be at least p$_0$ then thmaximum likelihood estimate under the constraint would be p=p$_0$.