Expected time to order hats A store has an inventory of hats. Customers arrive to buy hats according to a Poisson process with rate $2$ per day. A customer buys $1$ hat with probability $0.9$ and $2$ hats with probability $0.1$. Whenever the inventory drops to $7$ hats or less, the store immediately orders enough hats to return the inventory level to $10$ hats. Assume that the order of hats arrive instantaneously. What is the expected time between successive orders of hats?
My thought: I understand that I would need to find the probability there are exactly $n$ customer arrivals between successive orders of hats, for each value of $n$. But I'm getting stuck here, as I could not condition on this probability regards to the successive orders (I could not figure out the distribution of those orders, although I know that that we need to order hats after the 3rd customer comes in). 
Could someone please help me out on this tricky problem?
 A: Let $C$ be the number of customers that arrive, $H_n$ the number of hats customer $n$ buys, and $D=\sum_{n=1}^C H_n$ the total number of hats bought (during one day). Then the generating functions of $C$ and $H_1$ are given by
\begin{align}
P_C(s) &:= \mathbb E\left[ s^C\right] = e^{2(s-1)}\\
P_H(s) &:= \mathbb E\left[ s^H\right] = \frac9{10}s + \frac1{10}s^2.
\end{align}
Since $D$ is a Poisson sum of i.i.d. nonnegative integer-valued random variables, it follows that the generating function of $D$ is
\begin{align}
P_D(s) &:= \mathbb E\left[ s^D\right]\\
&\;= P_C(P_H(s))\\
&= e^{2\left(\frac9{10}s + \frac1{10}s^2 -1 \right)}\\
&= e^{\frac15\left(s-1\right)\left(s+10\right)}.
\end{align}
From the identity
$$\mathbb P(D=k) = \frac{P_D^{(k)}(0)}{k!} $$ we compute
\begin{align}
\mathbb P(D=0) &= e^{-2}\\
\mathbb P(D=1) &= \frac95 e^{-2}\\
\mathbb P(D=2) &= \frac{91}{50}e^{-2}\\
\mathbb P(D=3) &= \frac{333}{250}e^{-2}\\
\end{align}
and accordingly
\begin{align}
\mathbb P(D\geqslant1) &= 1-e^{-2}\\
\mathbb P(D\geqslant2) &= 1-\frac{14}5e^{-2}\\
\mathbb P(D\geqslant3) &= 1-\frac{231}{50}e^{-2}.
\end{align}
Let $d_n:=\mathbb P(D=n)$ and $\bar d_n:= \mathbb P(D\geqslant n)$. Let $X_n$ be the number of hats at the end of day $n$ (after customers purchase and an order, if placed, arrives), then $\{X_n:n=0,1,2,\ldots\}$ is a Markov chain on $\{10,9,8\}$ with transition matrix
$$
P=\begin{pmatrix}
d_0 + \bar d_3& d_1 & d_2\\
\bar d_2& d_0 & d_1\\
\bar d_1& 0 & d_0
\end{pmatrix} = \begin{pmatrix}
1 - \frac{181}{50}e^{-2} & \frac95 e^{-2} & \frac{91}{50}e^{-2}\\
1-\frac{14}5e^{-2} & e^{-2} & \frac95 e^{-2}\\
1-e^{-2}& 0 & e^{-2}
\end{pmatrix}
$$
Conditioned on $X_0=i,$ $i=10,9,8$ let $\tau_i$ be the expected time until the next order; that is,
$$\tau_i = \mathbb E\left[\inf\{n>0: X_n=10\mid X_0=i, D_n>0 \}\right]. $$
We have the system of equations
\begin{align}
\mathbb \tau_{10} &= \bar d_3 + d_0(\tau_{10}+1) + d_1(\tau_9+1) + d_2(\tau_8+1)\\
\mathbb \tau_9 &= \bar d_2 + d_0(\tau_9+1) + d_1(\tau_8+1)\\
\mathbb \tau_8 &= \bar d_1 + d_0(\tau_8+1),
\end{align}
with unique solution
\begin{align}
\tau_{10} &= \frac{e^2 \left(1+e^2\right) \left(31+50 e^2\right)}{50 \left(e^2-1\right)^3}\approx 1.90359\\
\tau_9 &= \frac{e^2 \left(4+5 e^2\right)}{5 \left(e^2-1\right)^2}\approx 1.48235\\
\tau_8 &= \frac{e^2}{e^2-1}\approx1.15652.
\end{align}
