# Stochastic Processes V
Devon DeJohn, Fall 2019
## M/G/1 Queue
Arrivals are a Poisson process with rate $\lambda.$ Still only one server. Service time is now a general random variable (anything but exponential), i.e., no lack-of-memory.
Let $S$ be the length of service $\sim f(s).$
### Expected waiting time in queue
$E(W_Q) = E(X_Q)\cdot E(S) + E(\text{remaining time for person in service}).$
After lots of work, we end up with
$$
\boxed{
E(W_Q) = \frac{\lambda}{2} \left(\frac{E(S)^2 + \text{var}(S)}{1-\lambda\;E(S)}\right)
}
$$
Note that $E(W_Q)$ depends on both $E(S)$ and $\text{var}(S).$ By Little's theorem, we have
$$
E(X_Q) = \lambda\;E(W_Q) \implies \boxed{E(X_Q) = \frac{\lambda^2}{2}\left(\frac{E(S)^2+\text{var}(S)}{1-\lambda\;E(S)}\right)}
$$
Furthermore we have the total time in the system as $\boxed{E(W)=E(W_Q)+E(S)}.$
`ex` Suppose we have $\lambda=5$ per hour, and service $\sim U(4,\,8)$ minutes.
What is the expected time in the queue? We need $E(S) = 6$ and $\text{var}(S) = \frac{(b-a)^2}{12} = \frac{4}{3}.$ We have $\lambda = 5/hr\implies \lambda=\frac{1}{12}$ in minutes.
$$
E(W_Q)=\frac{\frac{1}{12}}{2}\left(\frac{6^2 + \frac{4}{3}}{1-\frac{1}{12}\;6}\right) \approx 3.111
$$
$$
E(X_Q) = \frac{1}{12}\,E(W_Q) \approx \frac{1}{4}
$$
Now suppose $S\sim U(1,\,11).$ We still have $E(S)=6$ but now $\text{var}(S) = \frac{100}{12}\approx 8.333.$
So $E(W_Q) = \frac{\frac{1}{12}}{2}\left(\frac{6^2 + 8.333}{1-\frac{1}{12}\;6}\right) \approx 3.7.$
### Expected continuous busy/idle period
Busy will be denoted $B,$ idle denoted as $I.$
$$
\boxed{E(B) = \frac{E(S)}{1-\lambda\,E(S)}}
$$
Likewise,
$$
\boxed{E(I) = \frac{1}{\lambda}}
$$
## Brownian zero-sum game
Basic assumptions:
1. open information game
2. both players are equally smart
3. threshold strategy $\implies$ determine $a>0$ such that you offer to double as soon as $X(t)=a$
4. at the point of indifference, choose to double
Fact: for a symmetric Brownian motion with $X(0)=0,$ the probability you are up by some amount $A$ before you are down $B,$ is
$$
P(up\;A\;before\;down\;B) = \frac{B}{A+B} \\
P(down\;B\;before\;up\;A) = \frac{A}{A+B}
$$
If we double at $X(t)=a,$ our opponent accepts **iff** $E(gain\;|\;accept) > -100.$
Now $E(opponent\;gain\;|\;accept\;at\;x=a) = 200\cdot P(win)-200\cdot P(lose),$ we have $A=1-a$ and $B=1+a,$
\begin{align}
P(win) &= P(down\;B\;before\;up\;A) = \frac{A}{A+B} \\\\
&= 200\left(\frac{1-a}{2}\right) - 200\left(\frac{1+a}{2}\right) = -200\,a
\end{align}
So our opponent will accept the doubling **iff** $a\leq\frac{1}{2}.$
BUT, our opponent can now double which influences *their* decision to double!
Since this is a zero-sum game,
$$
E(opponent\;gain\;|\;dbl\;at\;x=a) \geq -100 \iff E(your\;gain\;|\;dbl\;at\;x=a)\leq 100
$$
So
$$
E(gain\;|\; accept) = 100
$$
Let $a^*$ be the borderline point, $x(t)=a^*.$