\documentclass{article}
% \documentclass[twocolumn]{article}

\setlength{\oddsidemargin}{-0.5in}
\setlength{\evensidemargin}{-0.5in}
\setlength{\topmargin}{0.0in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\setlength{\textwidth}{7.0in}
\setlength{\textheight}{9.5in}
\setlength{\parindent}{0in}
\setlength{\parskip}{0.05in}
\setlength{\columnseprule}{0.3pt}
\usepackage{fancyvrb}
\usepackage{relsize}
\usepackage{hyperref}

\usepackage{amsmath}

\begin{document}

Name: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

Directions: {\bf Work only on this sheet} (on both sides, if needed); do not
turn in any supplementary sheets of paper. There is actually plenty of room
for your answers, as long as you organize yourself BEFORE starting writing.
SHOW YOUR WORK.  Some problems may require answers to be in the form of
numerical expression.  An example is

\begin{equation*}
2/7 \cdot 1.39 + \sqrt{29.002} + \int_0^10.8 2t ~ dt  +
(1,2)  
\left (
   \begin{array}{cc}
   1 & 4 \\
   6 & 1   
   \end{array}
\right )     
\left (
   \begin{array}{c}
   6  \\
   6    
   \end{array}
\right )     
\end{equation*}
 
No variables are allowed in numerical expressions, nor are ``sigma sum''
series.

{\bf 1.}  Suppose packets on a network are of three types.  In general,
40\% of the packets are of type A, 40\% have type B and 20\% have type
C.  We observe six packets, and denote the numbers of packets of types
A, B and C by X, Y and Z, respectively.

\begin{itemize}

\item [(a)] (15) Give a numerical expression for P(X = Y = Z = 2).

\item [(b)] (15) Give a numerical expression for Cov(X,Y+Z).

\item [(c)] (10) Which one of the following is the distribution of Y+Z?

   \begin{itemize}

   \item [(i)] Binomial.

   \item [(ii)] Multinomial.

   \item [(iii)] Negative binomial.

   \item [(iv)] Poisson.

   \item [(v)] Uniform.

   \item [(vi)] Exponential.

   \item [(vii)] A distribution not listed above.

   \item [(viii)] None; Y+Z doesn't have a distribution.

   \end{itemize}

\end{itemize}

{\bf 2.} Suppose X and Y are independent, each having an exponential
distribution with means 1.0 and 2.0, respectively.

\begin{itemize}

\item [(a)] (15) Give a numerical expression for $P(Y > X^2)$.

\item [(b)] (10) Fill in the subscripts for f and the upper limit in the
second integral:

   \begin{itemize}

   \item [(i)] 
   
   $f_{
         \fbox{
            \parbox[c]{0.25in}{\ \ \ \ \ \ \ \newline \ \ \ \ }
         } 
      }(t)
   = \int_{0}^t e^{-s} \cdot 0.5 e^{-0.5(t-s)} ~ ds$
   
   \item [(ii)] 
   $f_{
         \fbox{
            \parbox[c]{0.25in}{\ \ \ \ \ \ \ \newline \ \ \ \ }
         } 
      }(t)
   = \int_{0}^
      {  
         \fbox{
            \parbox[c]{0.25in}{\ \ \ \ \ \ \ \newline \ \ \ \ }
         } 
      }
      e^{-s} \cdot 0.5 e^{-0.5(t/s)} ~ ds$

   \end{itemize}

\end{itemize}

{\bf 3.}  Consider the following extension the R code on p.98 (second
version of the bus simulation).  Note that {\bf nreps} is 100.

\begin{Verbatim}[fontsize=\relsize{-1}]
doexpt <- function(opt) {
   lastarrival <- 0.0
   nexttolastarrival <- 0.0
   while (lastarrival < opt) {
      nexttolastarrival <- lastarrival
      lastarrival <- lastarrival + rexp(1,0.1)
   }
   returnvalue <- c(opt-nexttolastarrival,lastarrival-opt)
   return(returnvalue)
}

observationpt <- 240
nreps <- 100
timessincelastbus <- vector(length=nreps)
waitstonextbus <- vector(length=nreps)
for (rep in 1:nreps) {
   de <- doexpt(observationpt)
   timesincelastbus[rep] <- de[1]
   waitstonextbus[rep] <- de[2]
}
wbar <- mean(waitstonextbus)
cat("approx. mean wait =",wbar,"\n")
s2 <- mean(waitstonextbus^2) - wbar^2
s <- sqrt(s2)
radius <- 1.96*s/sqrt(nreps)
cat("approx. CI for EW =",wbar-radius,"to",wbar+radius,"\n")
\end{Verbatim}

\begin{itemize}

\item [(a)] (15) Give a numerical expression, which will involve the
N(0,1) cdf $\Phi$, for the approximate value of $P(\overline{W} > 10.5$.

\end{itemize}

In parts (b) and (c), let V denote the time elapsed from the previous
bus arrival to the current observation point, i.e. how long it has been
since the previous bus arrived.

\begin{itemize}

\item [(b)] (10) Give a single line of code, to be added at the end of the
code above, that will print out the approximate value of Cov(V,W).

\item [(c)] (10) Give a numerical expression for $P(V+W > 12.2)$.

\end{itemize}

{\bf Solutions:}

{\bf 1.}

\begin{itemize}

\item [(a)] Straightforward multinomial:

\begin{equation}
\frac{6!}{2!2!2!} 0.4^2 0.4^2 0.2^2
\end{equation}

\item [(b)] 

\begin{eqnarray}
Cov(X,Y+Z) &=& Cov(X,Y) + Cov(X,Z) ~ \textrm{(props. of Cov())} \\ 
&=& 6[ -0.4 0.4 -0.4 0.2] ~ \textrm{(p.76)}
\end{eqnarray}

\item [(c)]  Y+Z is the count of the number of packets having type
either B or C.  This is a binomial situation---6 trials, each trial
resulting in either success (packet type B or C) or failure (type not B
or C), with our random variable Y+Z being the count of the number of
successes.

Those who did not see this should have \underline{eliminated} choice
(ii) immediately.  The root ``multi'' means ``more than one'', but we
have ONLY ONE variable here, Y+Z.  The fact that that variable arises as
a sum of two others is irrelevant; it's one variable.

\end{itemize}

{\bf 2.}

\begin{itemize}

\item [(a)]

\begin{equation}
P(Y > X^2) = 
\int_{0}^{\infty} ~ 
\int_{s^2}^{\infty}
f_{X,Y}(s,t) ~
dt ~ ds
\end{equation}

Since X and Y are independent,

\begin{equation}
f_{X,Y}(s,t) = f_X(s) f_Y(t)
= e^{-s} ~ 0.5 e^{-0.5t}
\end{equation}

\item [(b)]

   \begin{itemize}
   
   \item [(i)] X+Y.  This is exactly the convolution integral.
   
   \item [(ii)] XY, with an upper limit of $\infty$.  It's not convolution,
   but one uses the same reasoning as in the derivation of the convolution.
   
   \end{itemize}

\end{itemize}

{\bf 3.}

\begin{itemize}

\item [(a)] Straightforward computation involving $\bar{W}$.  The latter
is approximate normal, with mean 10 and variance $Var(W)/n = 10^2/100 =
1$.  Thus 

\begin{equation}
\frac{\bar{W} - 10}{1}
\end{equation}

has an approximate N(0,1) distribution, and the answer is

\begin{equation}
1-\Phi(10.5-10)
\end{equation}

\item [(b)] Cov(V,W) = E(VW) - EV EW so its estimate is

\begin{equation}
\frac{1}{n} \sum_{i=1}^n V_i W_i - \bar{V} \bar{W}
\end{equation}

The line of code is then

\begin{Verbatim}[fontsize=\relsize{-2}]
cat("approx. cov(V,W) = ",mean(timessincelastbus*waitstonextbus) -
   mean(timessincelastbus)*wbar
\end{Verbatim}

I very reluctantly allowed people to use {\bf cov()}.  It works, but is
not in our course materials, and many people probably just guessed.

\item [(c)] From our material on the Bus Paradox, p.52, we know that

\begin{equation}
f_{V+W}(t) = 0.01 t e^{-0.1t}
\end{equation}

so

\begin{equation}
P(V+W > 12.2) = \int_{12.2}^{\infty} 0.01 t e^{-0.1t} ~ dt
\end{equation}

\end{itemize}

\end{document}

