\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.} (15) On Section 6.4, find $E(X^3)$.

{\bf 2.} (15) On p.119, suppose $Z$ is the number of heads obtained from
three tosses of a coin, rather than two.  Find $F_Z(1.88)$.  Write your
answer only as a numerical expression, NO calls to R functions.

{\bf 3.} (15) Suppose $f_{X}(t) = ct^2$ for $0 < t < 2$, 0 elsewhere, for
some constant $c$.  Find $c$.

{\bf 4.} (15) Consider the coin-and-die game, Section 4.15.3.  You don't
observe the game personally, but you hear that the player took at most 2
turns to roll a 5.  Find the probability that the player wins exactly
\$1.

{\bf 5.} (15) The following simulation finds and returns the long-run
average seek distance in the disk drive model, pp.126ff.  Fill in the
blanks:

\begin{lstlisting}
sim <- function(nreps) {
   # start at the middle track, 
   # but doesn't matter
   oldtracknum <- 0.5
   seeks <- vector(length=nreps)
   for (i in 1:nreps) {
      tracknum <-  blank (a)
      seeks[i] <-  blank (b)
      oldtracknum <- tracknum
   }
   blank (c)
\end{lstlisting}

{\bf 6.} Consider the Markov inventory model, p.112, and the
following run of the code:

\begin{lstlisting}
> inventory(0.8,0.2,5)
[1] 0.1936083 0.1932367 0.1950948 
0.1858045 0.2322557
\end{lstlisting}

\begin{itemize}

\item [(a)] (15) Find the proportion of days in which a customer leaves
emptyhanded.

\item [(b)] (10) Find the proportion of customers who leave emptyhanded.

\end{itemize}

\onecolumn

\newpage

{\bf Solutions:}

{\bf 1.}

$$
\int_{1}^{4} t^3 \cdot 2t/15 ~ dt
$$

{\bf 2.} 

\begin{lstlisting}
pbinom(1,3,0.5)
\end{lstlisting}

{\bf 3.}  The density must integrate to 1.  Solving for $c$ yields the
value 3/8.

{\bf 4.}

$$
P(W = 1 | M \leq 2) 
= \frac{P(W = 1 \textrm{ and } M \leq 2)}{P(M \leq 2)} 
$$

The denominator is

$$
\frac{1}{6} + 
\frac{5}{6} \cdot 
\frac{1}{6} 
$$  

and the numerator is

$$
P(W = 1 \textrm{ and } M = 1) +
P(W = 1 \textrm{ and } M = 2) =
\frac{1}{6} \cdot \frac{1}{2} +
\frac{5}{6} \cdot \frac{1}{6} \cdot 2 (1-\frac{1}{2}) \frac{1}{2} 
$$

{\bf 5.}

\begin{lstlisting}
sim <- function(nreps) {
   oldtracknum <- 0.5
   seeks <- vector(length=nreps)
   for (i in 1:nreps) {
      tracknum <- runif(1)
      seeks[i] <- abs(tracknum - oldtracknum)
      oldtracknum <- tracknum
   }
   mean(seeks)
}
\end{lstlisting}

{\bf 6.a}

$$
0.1936083 \cdot 0.2
$$

{\bf 6.b}  Think of what will happen over the course of 10000 days.  We
will have approximately 12000 customers, among whom 

$$
0.1936083 \cdot 0.2 \cdot 10000
$$

will leave emptyhanded.  Then divide.

\end{document}

