# inverting the binomial distribution: probability distribution for number of trials necessary to have a given number of successes

The binomial distribution gives me a distribution for the number of successes in several Bernoulli trials, k, given parameters N the total number of trials and q, the success probability for one trial. This probability can be thought of as P(k|N,q).

Assuming that q is known I would be interested in P(N|k,q), which should follows from Bayes rule, and I am not sure which prior should be used for N. I also wonder if a classical distribution exists in the literature that is what I am looking for.

When building one's prior, consider the likelihood function $$\ell(N|k,q)={N \choose k} q^k (1-q)^{N-k}\propto \dfrac{N!}{(N-k)!} (1-q)^{N}\mathbb{I}_{N\ge k}$$ which is not from an exponential family wrt to $N$. Hence does not allow for the so-called conjugate priors which are often used because of their rather simple features, rather than for theoretical reasons. This means that the prior on $N$ has to be constructed from prior information on the possible size of the population, $N$. If this information is found missing, an alternative is to consider the marginal distribution on $k$ $$m(k)=\sum_{N=k}^{\infty} \pi(N) \ell(N|k,q)$$ as the shape of this posterior may help comparing different choices of priors.
If nothing else works, a default (but not the default) prior is the non-informative $$\pi(N)\propto 1/N \mathbb{I}_{\mathbb{N}^+}(N)$$ which stems from the notion that $N$ is a form of scale parameter, $k$ being of order $qN$.