% \documentclass{article}
\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}
\usepackage{fancyvrb}
\usepackage{relsize}
\usepackage{hyperref}

\usepackage{amsmath}

\begin{document}

Name: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

Directions: {\bf Work only on this sheet} (on both sides, if needed); do not
turn in any supplementary sheets of paper. There is actually plenty of room
for your answers, as long as you organize yourself BEFORE starting writing.
SHOW YOUR WORK.  Some problems may require answers to be in the form of
numerical expression.  An example is

\begin{equation*}
2/7 \cdot 1.39 + \sqrt{29.002} + \int_0^10.8 2t ~ dt  +
(1,2)  
\left (
   \begin{array}{cc}
   1 & 4 \\
   6 & 1   
   \end{array}
\right )     
\left (
   \begin{array}{c}
   6  \\
   6    
   \end{array}
\right )     
\end{equation*}
 
No variables are allowed in numerical expressions.

{\bf 1.} (10) Suppose 20\% of all C++ programs have at least one major
bug.  Out of five programs, what is the probability that exactly two of
them have a major bug?  Give your answer as a numerical expressions.

{\bf 2.} (10) Suppose $f_X(t) = 3t^2$ for t in (0,1) and is zero
elsewhere.  Give numerical expressions for $F_X(0.5)$ and $E(X)$.

{\bf 3.}  Our experiment is to toss a nickel until we get a head, taking
X rolls, and then toss a dime until we get a head, taking Y tosses.
Give numerical expressions for the following quantities:

\begin{itemize}

\item [(a)] (5) P(X = 2).

\item [(b)] (5) P(X+Y = 3).

\item [(c)] (10) Var(X+Y).

\item [(d)] (10) Long-run average in a ``notebook'' column labeled $X^2$.

\end{itemize}

{\bf 4.}  Suppose light bulb lifetimes X are exponentially distributed
with mean 100 hours.  Answer using numerical expressions:

\begin{itemize}

\item [(a)] (5) Find the probability that a light bulb burns out before
25.8 hours.

\end{itemize}

In the remaining parts, suppose we have two light bulbs.  We install the
first at time 0, and then when it burns out, immediately replace it with
the second.

\begin{itemize}

\item [(b)] (5) Find the probability that the first light bulb lasts less
than 25.8 hours and the lifetime of the second is more than 120 hours.

\item [(c)] (10) Find the probability that the second burnout occurs after
time 192.5.

\end{itemize}

{\bf 5.} (10) Assume the ALOHA network model as in pp.1-2, i.e. m = 2 and
$X_0 = 2$, but with general values for p and q.  Find the probability
that a new message is created during epoch 2.

{\bf 6.}  Consider the trick coin example near the end of Chapter 1.

\begin{itemize}

\item [(a)] (10) Find $P(A_{10000})$.

\item [(b)] (10) Write R code to find the probability in (a) by
simulation.

\end{itemize}

{\bf Solutions:}

{\bf 1.} 

\begin{equation}
\binom{5}{2} 0.2^2 0.8^3
\end{equation}

{\bf 2.} 

\begin{equation}
F_X(0.5) = \int_0^{0.5} ~ 3t^2 dt 
\end{equation}

\begin{equation}
EX = \int_0^1 ~ t \cdot 3t^2 dt 
\end{equation}

{\bf 3.a} $0.5^2$

{\bf 3.b} $0.5 \cdot 0.5^2 \cdot 2$

{\bf 3.c}  Due to independence, Var(X+Y) = Var(X) + Var(Y).  Then use
the formula for variance of a geometric distribution.

{\bf 3.d}  $E(X^2) = Var(X) + (EX)^2$.  Then use the formulas for
mean and variance of a geometric distribution.

{\bf 4.a}

\begin{equation}
\int_0^{25.8} ~ 0.01 e^{-0.01t} dt
\end{equation}

{\bf 4.b}

\begin{equation}
\left ( \int_0^{25.8} ~ 0.01 e^{-0.01t} dt \right )
\left ( \int_{120}^{\infty} ~ 0.01 e^{-0.01t} dt \right )
\end{equation}

{\bf 4.c}  The sum of the two random variable has an Erlang distribution
with $r = 2, \lambda = 0.01$, so the probability is

\begin{equation}
\int_{192.5}^{\infty} ~ 0.01^2 t e^{-0.01t} dt
\end{equation}

{\bf 5.}  Let A be the event that there is a successful transmit in
epoch 1, and B be the event that a new message is created in epoch 2.
Then

\begin{eqnarray}
\textrm{P(B)} &=& \textrm{P(A and B)} \\
&=& \textrm{P(A)} \cdot \textrm{P(B$|$A)} \\
&=& 2p(1-p) \cdot q
\end{eqnarray}

{\bf 6.a}  The probability is 0.5.  See Equation (1.88) and the
discussion before and after it.

{\bf 6.b}

\begin{Verbatim}[fontsize=\relsize{-2}]
count <- 0
nreps <- 1000
for (i in 1:nreps) {
   if (runif(1) < 0.5) pheads <- 0.9 else pheads <- 0.1
   tosses <- runif(10000)
   if (tosses[10000] < pheads) count <- count + 1
}
print(count/nreps)
\end{Verbatim}

\end{document}

