I have detector which will detect an event with some probability p. If the detector says that an event occured, then that is always the case, so there are not false-positives. After I run it for some time, I get k events detected. I would like to calculate what the total number of events that occured was, detected or otherwise, with some confidence, say 95%.
So for example, let's say I get 13 events detected. I would like to be able to calculate that there were between 13 and 19 events with 95% confidence based on p.
Here's what I've tried so far:
The probability of detecting k events if there were n total is:
binomial(n, k) * p^k * (1 - p)^(n - k)
The sum of that over n from k to infinity is:
1/p
Which means, that the probability of there being n events total is:
f(n) = binomial(n, k) * p^(k + 1) * (1 - p)^(n - k)
So if I want to be 95% sure I should find the first partial sum f(k) + f(k+1) + f(k+2) ... + f(k+m)
which is at least 0.95 and the answer is [k, k+m]
. Is this the correct approach? Also is there a closed formula for the answer?
Best Answer
I would choose to use the negative binomial distribution, which returns the probability that there will be X failures before the k_th success, when the constant probability of a success is p.
Using an example
the mean and sd for the failures are given by
The distribution of the failures X, will have approximately that shape
So, the number of failures will be (with 95% confidence) approximately between
and
So you inerval would be [k+qnbinom(.025,k,p),k+qnbinom(.975,k,p)] (using the example's numbers [21,38] )