# What is the distribution for the time before K successes happen in N trials?

What is the distribution for the time before K successes happen in N trials?

Suppose there is a telephone center, and N people, each of whom will either call the telephone center in time T with probability p not call the telephone center with probability (1 - p). People can call only once. What is the expected time before K people call? T is distributed as a random exponential variable.

I am solving this computationally in R by drawing N observations from T, discarding samples with probability (1 - p), sorting the remaining observations and picking out the Kth one.

Is there any common way to do it analytically?

• Could you state the model with more detail: Is this correct: Each one of the $N$ persons, independently, makes a call with probability $p$. In the case they make the call, the waiting time until the call is distributed exponentially, with some known parameter $\lambda$. Then we ask for the $k$th order statistic of the calls? Jan 18, 2016 at 19:27
• Yes, that is correct. And then we ask for the time of the Kth call. Jan 18, 2016 at 19:32
• And what will you do in the case (presumably of low probability) that $K$ is larger that the actual number of realized calls? Jan 18, 2016 at 21:13
• Rodrigo, Can you include your R code to play with the problem exactly as you are explaining it? Jan 20, 2016 at 21:35

Suppose that $X_1,X_2,\dotsc,X_N$ are iid with the unit exponential distribution with density $f(x) = e^{-x}, x\ge 0$. (You can adapt the results to some other rate). But, each $X_i$ (the waiting time before person $i$ makes his phone call) will only be realized with some probability $p$, and with probability $1-p$ the call is not done and we do not observe that $X_i$. The number of realized calls $r$ has the binomial distribution $\text{bin}(N,p)$. So, reorder the variables so the realized calls (conditional on $r$) is $X_1,\dotsc,X_r$. Then, assuming that $K\le r$, you asked for the distribution of the order statistic $X_{K:r}$. Now, the theory of exponential order statistics is especially simple, so, using results taken from the book: Barry Arnold: "A First Course in Order Statistics", which I will not rederive here (but the proofs are really simple, and can be found here: https://math.stackexchange.com/questions/80475/order-statistics-of-i-i-d-exponentially-distributed-sample), transform the order statistics to exponential spacings, given by $$Z_1 = r X_{1:r}, \\ Z_2 = (r-1)(X_{2:r}-X_{1:r}) \\ \vdots \\ Z_r = X_{r:r}-X_{r-1:r}.$$ Then the surprising and simple result is that the variables $Z_1, Z_2, \dotsc,Z_r$ are iid distributed unit exponential.

By some algebra we get that $X_{K:r}$ has the same distribution as $\sum_{i=1}^K \frac1{r-i+1} Z_i$, that is, a linear combination of independent exponential random variables. If all the coefficients in the linear combination were equal, this would be a gamma distribution. Now it is a more complicated distribution which have been studied in http://www.tandfonline.com/doi/abs/10.1080/03610928308828483?journalCode=lsta20, for instance.

Now, you need to decide what you want to do in the case that $K>r$. Barring that problem, what you need now is simply the mixture distribution of $X_{K:r}$ over the binomial distribution of $r$.

If N is fixed and K is random, then the number of successes K is such that $K \sim Bin(N,p)$. You are not guaranteed to get K successes for any fixed K if N is also fixed.

Alternatively, if N is random and K is fixed, and you are wondering about the distribution of the number of trials, N, until K successes are achieved, then N $\sim NegBin(K,p)$ (note that different texts have different definitions of the negative binomial -- sometimes they only count failures rather than total trials).

The sum of k IID standard Expos is Gamma(k,1).

Assuming the negative binomial scenario, you have $T \mid N \sim Gamma(N,1)$ and $N \sim NegBin(K,p)$.

I don't know if there is a nice formula for this hierarchical model but you should be able to get the expectation easily using the law of total expectation, conditioning on N. E(T) = E(E(T|N))

The time is the $K$'th order statistic of $N'$ iid exponential distributions where $N'$ is binomial distributed with parameters $N, p$. Each order statistic is distributed as in this solution described below, which you mix over the outcomes of $N'$.

Let $\lambda$ be the rate of $T$. Then the first order statistic of $N'$ exponential distributions having rate $\lambda$ is exponentially distributed with rate $N' \lambda$ since it's as if $N'$ Poisson processes race against each other and the winner's time is the same as the waiting time of the superposition. The second order statistic adds on an exponential distribution with rate $(N'-1)\lambda$ since one less Poisson process is racing, and so on...