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

\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 1.} This problem concerns the bus ridership example, which begins
in Sec. 2.11 and is analyzed via simulation in Sec. 2.12.4.

\begin{itemize}

\item [(a)] (25) Find $E(B_1)$.

\item [(b)] (20) Suppose the company charges \$3 for passengers who board
at the first stop, but charges \$2 for those who join at the second
stop.  (The latter passengers get a possibly shorter ride, thus pay less.)
So, the total revenue from the first two stops is $T = 3 B_1 + 2 B_2$.
We want to find E(T), and the question is whether we can calculate it by
first writing

\begin{equation}
E(T) = 3 E(B_1) + 2 E(B_2)
\end{equation}

then using our answer from (a) above, and then reasoning that $E(B_2) =
E(B_1)$.  Which of the following is correct?

   \begin{itemize}

   \item [(i)]  The method proposed above is valid.  (If you choose this
   answer, you must also state the numbers of the relevant ``mailing
   tubes.'')

   \item [(ii)] The above method is invalid, because $E(B_2)$ is not
   necessarily equal to $E(B_1)$.

   \item [(iii)] $E(B_2) = E(B_1)$, but the above method is invalid for
   other reasons.

   \end{itemize}

\item [(c), (d)] (20)  (Note that the following concerns both part (d) and
part (d).)  Suppose on p.24 we wish to add code to find $E(L_{10})$, not
just $P(L_{10} == 0$ as we are already doing.  We'll need to insert two
new lines of code for this (not counting another {\bf print()} call
after line 17).  State what these two lines are, for your answers to (c)
and (d).  Include a comment, saying {\it where} the insertions should be
made.  Example:  If the code {\bf x \lstinline{<-} y + 3} should go
between lines 8 and 9, write

\begin{Verbatim}[fontsize=\relsize{-2}]
x <- y + 3  # insert between lines 8 and 9
\end{Verbatim}

\end{itemize}

{\bf 2.}  Twenty tickets are sold in a lottery, numbered 1 to 20,
inclusive.  Five tickets are drawn for prizes.

\begin{itemize}

\item [(a)] (25) Find the probability that two of the five winning tickets are
even-numbered.  (You may call built-in R functions, e.g. {\bf sqrt()} in
your answer.)

\item [(b)] (10) Find the probability that two of the five winning tickets
are in the range 1 to 5, two are in 6 to 10, and one is in 11 to 20.
(You may call built-in R functions, e.g. {\bf sqrt()} in your answer.)

\end{itemize}

\onecolumn

{\bf Solutions:}

{\bf 1.a}

\begin{equation}
E(B_1) = 
0 \cdot P(B_1 = 0) + 
1 \cdot P(B_1 = 1) + 
2 \cdot P(B_1 = 2) = 0.4 + 2 \cdot 0.1
\end{equation}

{\bf 1.b} Answer (i) is correct, using (3.13) (taking $U = 3B_1$ and $V
= 2B_2$) and then (3.14). 

{\bf 1.c,d}  

\begin{lstlisting}[numbers=left]
totl10 <- 0  # insert between 3 and 4
totl10 <- totl10 + passengers  # insert between 15 and 16
\end{lstlisting}

{\bf 2.a}

\begin{lstlisting}[numbers=left]
choose(10,2) * choose(10,3) / choose(20,5)
\end{lstlisting}

{\bf 2.b}

\begin{lstlisting}[numbers=left]
choose(5,2) * choose(5,2) * choose(10,1) / choose(20,5)
\end{lstlisting}

\end{document}

