\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
sum()}, etc.  

{\bf 1.} In the R code at the bottom of p.69, suppose we wish to change
it to find $P(Y_6 = X_6)$.  Replace each of these lines below.
You may remove lines if you wish (do not add any); if so, replace the
given line with a comment line,

\begin{lstlisting}
# line removed
\end{lstlisting}

so that the original line numbers are retained.

\begin{itemize}

\item [(a)] (10) Show the new line 2.

\item [(b)] (10) Show the new line 3.

\item [(c)] (10) Show the new line 4.

\end{itemize}

{\bf 2.} Coin A has probability 0.6 of heads, Coin B is fair, and
Coin C has probability 0.2 of heads.  I toss A once, getting X heads,
then toss B once, getting Y heads, then toss C once, getting Z heads.
Let W = X + Y + Z, i.e. the total number of heads from the three tosses
(ranges from 0 to 3).

\begin{itemize}

\item [(a)] (10) Find P(W = 1).

\item [(b)] (10) Find Var(W).

\end{itemize}

{\bf 3.} This problem concerns the parking example, pp.59-60.

\begin{itemize}

\item [(a)] (15) Find $p_N(3)$.

\item [(b)] (10) Find P(D = 1).

\item [(c)] (10) Say Joe is the one looking for the parking place.  Paul
is watching from a side street at the end of the first block (the one
before the destination), and Martha is watching from an alley situated
right after the sixth parking space in the second block.  Martha calls
Paul and reports that Joe never went past the alley, and Paul replies
that he did see Joe go past the first block.  They are interested in the
probability that Joe parked in the second space in the second block.
Fill in the blank, using only math and probability symbols, N and D---no
English except for {\it and}, {\it or} and {\it not}:  The probability
they wish to find is
P(\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_).

\item [(d)] (15) Add to the simulation code on p.60, so that it finds
and prints (the latter via {\bf print()}) the approximate value of P(we
park in the first block).  You must use only one R statement, though it
will probably consist of nested function calls.  Hint:  See p. 21,
bottom.  \end{itemize}

{\bf 4.} (15) March, April, May and June\footnote{Each of these is a
common woman's name, by the way.} each roll a die until an event
occurs:  For March, the event is to roll a 3; for April, a 4; for May, a
5; and for June, a 6.  Let T denote the total number of rolls they make.
Find P(T = 28).

{\bf Solutions:}

{\bf 1.} 

\begin{lstlisting}
for (i in 0:4) 
   # line removed
   prob <- prob + dbinom(i,4,0.5) * dbinom(i,6,0.5)
\end{lstlisting}

{\bf 2a.} 

\begin{eqnarray*}
P(W = 1) &=& 
   P(X = 1 \textrm{ and }  Y = 0 \textrm{ and }  Z = 0 \textrm{ or }  ...) \\ 
   &=& 0.6 \cdot 0.5 \cdot 0.8 + 
       0.4 \cdot 0.5 \cdot 0.8 + 
       0.4 \cdot 0.5 \cdot 0.2 
\end{eqnarray*}

{\bf 2b.} Var(W) = Var(X) + Var(Y) + Var(Z), by independence.  Since X is
an indicator random variable, $Var(X) = 0.6 \cdot 0.4$, etc.  The answer
is

$$
0.6 \cdot 0.4 +
0.5 \cdot 0.5 +
0.2 \cdot 0.8 
$$


{\bf 3a.}

$$
p_N(3) = P(N = 3) = (1-0.15)^{3-1} 0.15
$$

{\bf 3b.}

\begin{eqnarray*}
P(D = 1) &=& P(N = 10 \textrm{ or } N = 12) \\ 
&=& (1-0.15)^{10-1} 0.15 + (1-0.15)^{12-1} 0.15
\end{eqnarray*}

{\bf 3c.} $P(N = 12 ~|~ N > 10 \textrm{ and } N < 16)$

{\bf 3d.}

\begin{lstlisting}
print(mean(nvalues <= 10))
\end{lstlisting}

{\bf 4.}  Actually, it doesn't matter what the different women's
numerical goals are; the probability would be the same even if each
woman was rolling until she got, say, a 5.  The random variable T is
then a sum of 4 independent geometrically-distributed random variables,
each having the parameter p = 1/6.  As noted in the material surrounding
(3.109), such a sum has a negative binomial distribution.  Thus
P(T = 28) is computed as

\begin{lstlisting}
choose(28-1,4-1) * (1-1/6)^(28-4) (1/6)^4
\end{lstlisting}


\end{document}

