\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}

\setlength\columnsep{25pt}

\usepackage{fancyvrb}
\usepackage{relsize}
\usepackage{hyperref}

\usepackage{listings}
\usepackage{amsmath}

\begin{document}

\lstset{xleftmargin=5mm,framexleftmargin=10mm,basicstyle=\footnotesize}

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

Directions: {\bf \Large Work only on this sheet} (on both sides, if
needed).  MAKE SURE TO COPY YOUR ANSWERS TO A SEPARATE SHEET FOR SENDING
ME AN ELECTRONIC COPY LATER.

{\bf Important note:}  Remember that in problems calling for R code, you
are allowed to use any built-in R function, e.g. {\bf choose()}.

{\bf 1.} This problem concerns the bus ridership example, which begins
in Sec. 2.11.  

\begin{itemize}

\item [(a)] (20) The bus driver has the habit of exclaiming, ``What?  No
new passengers?!'' every time he comes to a stop at which $B_i = 0$.
Let N denote the number of the stop (1,2,...) at which this first
occurs.  Find P(N = 3).

\item [(b)] (20) Find Var(N) in (a).

\item [(c)] (20) Let T denote the number of stops, out of the first 6,
at which 2 new passengers board.  For example, T would be 3 if $B_1 =
2$, $B_2 = 2$, $B_3 = 0$, $B_4 = 1$, $B_5 = 0$, and $B_6 = 2$.  Find
$p_T(4)$.

\item [(d)] (20) The bus ridership problem is simulated in Section 2.12.4.
Give a single call to a built-in R function that can replace lines 8-11.

\end{itemize}

{\bf 2.} (20) A machine contains one active battery and two spares.  Each
battery has a 0.1 chance of failure each month.  Let L denote the
lifetime of the machine, i.e. the time in months until the third battery
failure.  Find P(L = 12).

\onecolumn

{\bf Solutions:}

{\bf 1.a}  N has a geometric distribution, with p = probability of 0 new
passengers at a stop = 0.5.  Thus $p_N(3) = (1-0.5)^2 0.5$, by (3.75).

{\bf 1.b}  $Var(N) = (1-0.5) / 0.5^2$, by (3.84).

{\bf 1.c}  T has a binomial distribution, with n = 6 and p = probability
of 2 new passengers at a stop = 0.1.  Then

\begin{equation}
p_T(4) = \binom{6}{4} 0.1^4 (1-0.1)^{6-4}
\end{equation}

Note that your electronic answer could be

\begin{lstlisting}[numbers=left]
dbinom(4,6,0.1)
\end{lstlisting}

{\bf 1.d}  Given that k passengers are currently on the bus, the number
who alight has a binomial distribution, with n = k and p = 0.2.  The code
in lines 8-11 is merely simulating the k trials, in this case with k
being the variable named {\bf passengers}.  Thus the code could be
replaced by

\begin{lstlisting}[numbers=left]
passengers <- passengers - rbinom(1,passengers,0.2)
\end{lstlisting}

{\bf 2.}  The number of months until the third failure has a negative
binomial distribution, with r = 3 and p = 0.1.  Thus the answer is
obtained by (3.111), with k = 12: 

\begin{equation}
P(L = 12) = \binom{11}{2} (1-0.1)^9 0.1^3 
\end{equation}

\end{document}

