I have a process which succeeds with known probability $p$, and fails with probability $q = 1-p$. The process is repeated a finite, but unknown, number of times $n$.
Given a number of successes $r$ (the number of failures $n-r$, is unknown), how should we determine a confidence interval around the number of trials that led to the $r$ successes?
To give a simple example, a fair coin was flipped a total of $n$ times, and landed 150 times with heads uppermost. How is $n$ distributed, and what is a 95% CI around its mean, covering the most likely values for $n$. The most likely $n$ is 300, the smallest $n$ is 150, and the maximum $n$ is infinity, but how do we think about everything in between?
Note: The interval doesn't have to be centered on the mean, if the distribution is not symmetric.
I've been looking at the wilson score, and other binomial proportion confidence intervals, and they are relevant, but they estimate $p$ instead, not $n$. I'm wondering if there exist similar approaches for exactly what I'm looking for.
Lacking a closed formula for an estimator, I was otherwise just going to try to find the ends of my confidence interval $(n_{low}, n_{high})$ by fitting the two gaussians with means $n_{low}p$ and $n_{high}p$ for which $\hat{n}p$ (where $\hat{n} = r/p$ is my estimated $n$) falls on their 2.5%-area tail boundary, using tables.
