# Average number of failures before success

By the title, you must instantly think that it's a geometric probability distribution (or perhaps binomial, by the story below) that I'm looking for, but my stats is failing me. Allow me to put this as a story:

An office worker is given 13 phone numbers for technical support. Each phone number will reach one and only one support agent. Each agent specializes in their own field. The office worker has no idea which agent can answer which question in advance.

When they have a query, they start phoning the numbers one by one, in some random, non-repeating order. They stop after they have reached the correct number. It is guaranteed that their query will be answered by only one support agent.

What is the average number of calls the worker needs to make? I.e. what is the average number of failures before he has a single success?

If I try with the geometric distribution, I have p = 1/13. The number of failures before a success is k = {0,1,2,3..12}, since there is a 1/13 chance that they will get success on the first trial. The mean is defined as (1-p)/p = 12. This translate into "The average number of calls the worker is expected to make is 12". This seems excessively high. Is this correct?

Thank you.

• Hi, if they pick say "12" , is it possible 12 can be called again before success?
Oct 4, 2011 at 12:08

I disagree with the answer given by @probabilityislogic. There is no geometric distribution here at all, truncated or otherwise.

One of 13 agents can answer the question. The worker calls the agents one by one until the worker reaches the agent who can answer the question. Let us number the agents as $1$, $2, \ldots, 13$ in the order in which they are called. Absent any other information, I presume that the agent who can answer the question is equally likely to be any of $1$, $2, \ldots, 13$, and so the average number of calls is $7$. The next question may lead to the agents being called in a different order, but the identity of the agent may be different too, and so the same analysis applies.

Alternative scenario to be considered: all the questions are on the same topic and can be answered by just one agent but the worker, being a slow learner, does not figure this out, and calls the agents in random order every time a question comes in. So the go-to agent is reached on the first, second, ...., thirteenth call with equal probability, and again, $7$ calls are required on average.

Added note: The simulation by @thias (cf. comment on probabilityislogic's answer) confirms my analysis.

• Thanks for pointing that out. The math in @probabilityislogic's answer looks cool, though :-) Oct 4, 2011 at 12:55
• Thank you, it makes sense. This was an analogy that I used to describe what is happening in my messaging middleware. There are a number of data consumers attached to the middleware, each being partitioned. The middleware forwards a message to each consumer, in turn, until one accepts the message. There is no way to predict which consumer will accept a particular message. Oct 4, 2011 at 13:35

What you require is a truncated geometric distribution. The usual geometric distribution has a support of $0,1,\dots$ (i.e. to infinity) whereas your one has support only up to $12$.

So you need to renormalise the pdf.

$$Pr(X=x|p)=Ap(1-p)^x\implies A^{-1}=\sum_{x=0}^{12}p(1-p)^x=1-(1-p)^{13}$$ $$\implies Pr(X=x|p)=\frac{p(1-p)^x}{1-(1-p)^{13}}$$

Now we take expectations over this pdf (letting $q=1-p=\frac{12}{13}$):

$$E(X|p)=\frac{p}{1-q^{13}}\sum_{x=0}^{12}xq^x$$ $$=\frac{pq}{1-q^{13}}\sum_{x=0}^{12}\frac{\partial}{\partial q}q^{x} =\frac{pq}{1-q^{13}}\frac{\partial}{\partial q}\sum_{x=0}^{12}q^{x}=\frac{pq}{1-q^{13}}\frac{\partial}{\partial q}\frac{1-q^{x+1}}{1-q}$$ $$=\frac{pq}{1-q^{13}}\frac{1-q^{12}-12q^{12}(1-q)}{(1-q)^2}$$ $$=\frac{q}{1-q}\times\frac{1-q^{12}-12q^{12}(1-q)}{1-q^{13}}=12\times 0.43=5.13$$

That last factor represents a correction to the usual mean, due to the range restriction. For the more general case, we have (again letting $q=1-p$ be the chance for failure):

$$Pr(X=x|N,q)=\frac{(1-q)q^x}{1-q^{N+1}}\;\;\;\;\;\;\;\;x\in\{0,1,\dots,N\}$$ $$E(X|q,N)=\frac{q}{1-q}\times\frac{1-q^{N}-Nq^{N}(1-q)}{1-q^{N+1}}$$

Both of these contain the usual geometric distribution as appropriate limits as $N\to\infty$

UPDATE

This answer actually assumes that all $13$ operators could be called on any of the trials. Hence the $p$ remains constant. However, as Dilas correctly points out, the proper distribution is uniform. You can see this by "direct counting", the chance of correct on the first call is $\frac{1}{13}$, and the chance of correct on the second call is $(1-\frac{1}{13})\frac{1}{12}=\frac{1}{13}$ (the second prob is $\frac{1}{12}$ because the operator won't call the first caller again). For general case we have a "telescoping product":

$$Pr(X=x|N)=\frac{1}{N+1-x}\prod_{j=0}^{x-1}(1-\frac{1}{N+1-j})=\frac{1}{N+1-x}\prod_{j=0}^{x-1}\frac{N-j}{N+1-j}=\frac{1}{N+1}$$

This gives the expected value of $7$

• cool derivation! Can you imagine why this simulation: n=1000000; z=rep(0,n); for( i in 1:n ){ z[i]=which(sample.int( 13, 13, replace=F)==5)}; mean(z); yields a value close to 7? I guess I do something wrong? Oct 4, 2011 at 11:48
• The update still makes the calculation look harder than it is. The problem has a natural symmetry: because it's just as likely that $i$ calls will be made as $14-i$ calls, the expectation clearly is $14/2=7$.
– whuber
Oct 4, 2011 at 13:59
• imagine the thirteen ranks of cards, just one suit, spades. Randomly pick a card. What are the chances the ace is the first card? What are the chances the ace is the 10th card?