\documentclass[twocolumn]{article}
% \documentclass{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: MAKE SURE TO COPY YOUR ANSWERS TO A SEPARATE SHEET FOR SENDING
ME AN ELECTRONIC COPY LATER.

{\bf 1.} (20) Consider the bus ridership example, Sec.\ 2.12.  Let $M$
denote the number of the first stop at which 2 people board the bus.  If
for instance 1 person boards at the first stop, no one boards at the
second stop and 2 people board at the third stop, then $M = 3$.  Find
$Var(M)$.

{\bf 2.} (15) Consider the fee structure in Sec.\ 4.11. Find $Var(T)$.

{\bf 3.} (15) Fill in the blanks:  Equation (6.13) (or its equivalent form
$\pi = P' \pi$) shows that $\pi$ is a/an
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ of $P$ (or $P'$ in the equivalent
form).

{\bf 4.} (15) In the example in Sec.\ 6.2, let's change the rules:  Once
you get a total of 10 or more, your score is reset to 0, rather than to
your total mod 10.  One line of code needs to be changed.  State which
line, and what the new contents of the line will be.

{\bf 5.} Consider some distribution family $\mathcal F$, indexed by a
parameter $r$.  The random variables having distributions in this family
have as {\it support} the set of nonnegative integers i.e.\ they take on
values 0,1,2,...

Suppose we have available ``d'' and ``p'' functions for this family,
with call forms {\bf da(k,r)} and {\bf pa(k,r)}, where {\bf k} is an
integer.  

Say we have random variables $X$ and $Y$, where the distribution of $X$
is in the family $\mathcal F$ with parameter $r = c$ and the
distribution of $Y$ is in the family $\mathcal F$ with parameter $r =
d$, with $X$ and $Y$ independent.  

\begin{itemize}

\item [(a)] (10) Give R code to calculate $P(X = i, ~ Y = j)$.

\item [(b)] (10) Let $V = max(X,Y)$.  Give R code to compute $F_V(m)$, for
a nonnegative integer $m$.

\item [(c)] (15) Let $W = X + Y$.  Give R code to find $P(W = m)$ for
a nonnegative integer $m$.  You will need to use a loop, but make sure
you have it on a single line, e.g.

\begin{lstlisting}
tot <- 0; for (i in 1:10) {tot <- tot + i}
\end{lstlisting}

\end{itemize}

\onecolumn

\newpage

{\bf Solutions:}

{\bf 1.} $M$ has a geometric distribution with $p = 0.1$. Use (4.12).

{\bf 2.}  $Var(T) = 9 Var(B_1) + 4 Var(B_2)$.  Then use mailing tubes to
find $Var(B_i)$, or better, use (3.106), since $L_1 = B_1$.

{\bf 3.} eigenvector

{\bf 4.} Change line 11 to

\begin{lstlisting}
if (k >= 10) k <- 0
\end{lstlisting}

{\bf 5.a}

\begin{lstlisting}
da(i,c) * da(j,d)
\end{lstlisting}

{\bf 5.b}

\begin{lstlisting}
pa(m,c) * pa(m,d)
\end{lstlisting}

{\bf 5.c}

\begin{lstlisting}
sum <- 0; for (i in 0:m) sum <- sum + da(i,c) * da(m-i,d)
\end{lstlisting}

\end{document}
