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

{\large \bf 
This entire quiz concerns the committee example in Sec.\ 3.9.2, pp.61ff.
Except for Problem 3(c), all answers are numeric.  As usual, numeric 
answers must be given as R expressions that evaluate to numbers.  Note
that there are 5 problems, 1-5.}

{\bf 1.} (10) Find $P(\textrm{first pick is women, second is man})$.

{\bf 2.} (15) Find $P(D = 0)$.  For full credit, use an appropriate R
function.

{\bf 3.} Consider the following simulation code:

\begin{lstlisting}
sim <- function(nreps) {
 reprecords <- matrix(nrow=nreps,ncol=5)
 for (rep in 1:nreps) {
    comm <- pickcommittee()
    reprecords[rep,1:4] <- comm
    tmp <- sum(comm)
    # find tmp-(4-tmp)
    reprecords[rep,5] <- 2*tmp-4  
 }
 reprecords
}

pickcommittee <- function() {
  # choose the 4-person committee, recording
  # each time whether a man is picked
  npeopleleft <- 9
  nmenleft <- 6
  pickedsofar <- NULL
  for (i in 1:4) {
     propmen <- nmenleft / npeopleleft
     manpicked <- 
        sample(0:1,1,prob=c(1-propmen,propmen))
     nmenleft <- nmenleft - manpicked
     npeopleleft <- npeopleleft - 1
     pickedsofar <- c(pickedsofar,manpicked)
  }
  pickedsofar
}
\end{lstlisting}

We then run

\begin{lstlisting}
> simout <- sim(100000)
\end{lstlisting}

We then print out some quantities, as seen below.

\begin{itemize}

\item [(a)] (15) What will be printed out from this?

\begin{lstlisting}
> mean(simout[,5])
\end{lstlisting}

\item [(b)] (15) What will be printed out from this?

\begin{lstlisting}
> mean(simout[,3])
\end{lstlisting}

\item [(c)] (20) What will be printed out from this?

\begin{lstlisting}
> rownums <- which(simout[,1] == 1)
> sum(simout[rownums,2]) / length(rownums)
\end{lstlisting}

{\bf Your answer here in Part (c) must be in ``P()'' form, using only
symbols in the book, e.g. P(D = 9).}

\end{itemize}

{\bf 4.} (15) Find $Var(G_4)$.

{\bf 5.} (10) Find $Cov(G_1,G_4)$.

\onecolumn

\newpage

{\bf Solutions:}

{\bf 1.} $(3/9) (6/8)$

{\bf 2.} We need $P(M = W = 2)$.  It is

\begin{lstlisting}
choose(6,2) * choose(3,2) / choose(9,4)
\end{lstlisting}

{\bf 3.a}  $ED = 4 /3$

{\bf 3.b}  $P(G_3 = 1) = 6/9$

{\bf 3.c}  $P(G_2 = 1 | G_1 = 1)$

{\bf 4.}  $G_4$ is an indicator random variable, and thus its variance
is $p(1-p)$, where $p = P(G_4 = 1) = 2/3$.

{\bf 5.}  We need to find

\begin{equation}
E(G_1 G_4) - EG_1 \cdot EG_4
\end{equation}

The latter term is $(6/9)^2$.  To find $E(G_1 G_4)$, use reasoning
similar to that on the top of p.63 to find that

\begin{equation}
E(G_1 G_4) = E(G_1 G_2) =
\binom{6}{2}
\binom{3}{0} /
\binom{9}{2} 
\end{equation}

\end{document}

