# Non-iterative way to compute mean time until a random event within a limited window?

Let's say I'm selling widgets, which people have the right to return if they are defective.

Consider that the probability of a particular widget returned on any particular day after its sale is $p$ (ie. its equally likely to be returned on any day after its sale). Obviously a given widget can only be returned once. Given p, I know I can calculate the expected time until an item is returned as follows:

With probability p, T=1. (The return happens tomorrow.) If it doesn't happen tomorrow, then we expect to wait the same amount of time starting then. This gives us:

$E(T) = p + (1-p)(E(T)+1)$

And we can solve for $E(T)$ to get:

$E(T) = 1/p$

However, what if if I don't accept returns after N days, and people know this so even if they want to return after N days - they won't even try (so I don't know that a return would have occurred).

The problem is that I want to come up with a way to estimate $p_n$ given an actual duration of time until a return is received - $d_n$.

My eventual goal is to come up with an overall estimate $P$ by taking the mean of a variety of values $p_1, p_2, ...$ I get for a number of independent widget returns.

Now I realize it may be preferable to take the mean of $d_1, d_2, ...$ and calculate $P=1/D$ from that, but some external constraints prevent me from taking that approach, I have to take the mean of the probabilities, the $p_N$ values.

With no return window this is easy, we just reverse $E(T) = 1/p$, to get (where $d$ is the observed duration until a return): $p=1/d$.

Now the question: If I don't get a return within the $N$ day time window, meaning that I don't know the actual return duration, but I know its greater than $N$, what $p$ value do I use to update my mean, to account for this observation?

Could it be $p=0$?

-
Note, sorry if this question looks familiar, it is a reformulation of a question I asked yesterday, but which I realized contained a fundamental error, with some additions. – sanity Feb 25 '11 at 14:31
$T$ is a geometric random variable. If $T$ is the time you get your first ticket then $Pr(T=k) = (1-p)^{k-1} p$, and the prob. you don't get a ticket in $N$ days is $(1-p)^N$. It's not clear how you define $E(T)$ for a fixed $N$. Do you mean $E(T|T\leq N)$? – Or Zuk Feb 25 '11 at 15:02
I will attempt to rewrite the question to clarify. – sanity Feb 25 '11 at 16:31
Ok, question completely re-written, would appreciate it if you could take a fresh look – sanity Feb 25 '11 at 16:50
So you deleted the other question? Thereby disappearing the work of those who tried to help you? Last time I ever answer a question of yours here. Better would have been to have left that question up with an edit explaining what was wrong and pointing readers to this new question. – Gerry Myerson Feb 26 '11 at 4:59

Ok, so you've got data and want to estimate $p$. This looks straightforward. $T$ is a 'truncated' geometric r.v. with $Pr(T=k) = (1-p)^{k-1} p$ for $k=1,..,N$ and, say, $Pr(T=N+1) = (1-p)^N$ - where $N+1$ marks that you didn't get a return on the first $N$ days. Now, given an observation of $T$ (the $i$-th day of return, where $i$ can be $1,..,N$, or $N+1$ indicating that there was no return), you want to estimate $p$. You can take the maximum likelihood estimator and indeed, if there was no return, the MLE will give you $p=0$.

I don't understand what do you mean by $p_1,p_2,..$. Do you just have different data points with the same $p$? in this case you need to maximize the overall likelihood, and for $n$ different times $d_1,..,d_n$ you get $\hat{p}= (n-r) / (\sum_{i=1}^n d_i - r)$ where $r$ is the number of times there were no returns. Or are you trying to estimate different $p_i$'s?

-