---
title: "Math 151 - Probability Theory - Homework 2"
author: "your name here"
date: "Due: Friday, September 4, midnight PDT"
output: pdf_document
---
## Important Note:
You should work to turn in assignments that are clear, communicative, and concise. Part of what you need to do is not print pages and pages of output. Additionally, you should remove these exact sentences and the information about HW scoring below.
Click on the *Knit to PDF* icon at the top of R Studio to run the R code and create a PDF document simultaneously. [PDF will only work if either (1) you are using R on the network, or (2) you have LaTeX installed on your computer. Lightweight LaTeX installation here: https://yihui.name/tinytex/]
> Either use the college's RStudio server (https://rstudio.pomona.edu/)
or install R and R Studio on to your personal computer.
See: https://research.pomona.edu/johardin/math151f20/ for resources.
```{r warning=FALSE, comment=FALSE, message=FALSE, echo = FALSE}
knitr::opts_chunk$set(message=FALSE, warning=FALSE, fig.height=3, fig.width=5,
fig.align = "center")
```
### Assignment
**Book problems**
* Feel free to do the book problems with a pencil or in LaTeX (RMarkdown supports writing mathematics using LaTeX).
* If you use a pencil, just append your pencil pdf to the RMarkdown created when you knit your R code.
* If you have the 3rd edition of the book, the problems will be the same unless they don't exist -- that is, the 4th edition *added* problems but didn't change the order of them. Ask me if you want to see the 4th edition problems.
#### 1: PodQ
Describe one thing you learned from someone in your pod this week (it could be: content, logistical help, background material, R information, etc.) 1-3 sentences.
#### 2: 1.4.4
Prove Theorem 1.4.11. Note: the intersection $\bigcap$ is often written as a product, i.e., AB is the same as A$\bigcap$B.
There are four things to prove: For two arbitrary events $A$ and $B$, prove that $AB$ and $AB^c$ are disjoint. Also prove that $A = AB \cup AB^c$. In addition, $B$ and $A B^c$ are disjoint and $A \cup B = B \cup (A B^c ).$
#### 3: 1.4.6
For example, a reasonable description of $A^c$ would be "the event that an odd card is selected" (a description in words), or "the set of outcomes: {Red1, Red3, Red5, Red7, Red9, Blue1, Blue3, Blue5, Blue7, Blue9}" (a description as a subset of S).
Suppose that one card is to be selected from a deck of 20 cards that contain 10 red cards numbered from 1 to 10 and 10 blue cards numbered 1 to 10. Let $A$ be the event that a card with an even number is selected; let $B$ be the event that a blue card is selected; and
let $C$ be the event that a card with a number less than 5 is selected. Describe the sample
space, $S$, and describe each of the following events both in words and as subsets of $S$.
a. $ABC$, b. $BC^c$, c. $A \cup B \cup C$, d. $A(B \cup C)$, and e. $A^cB^cC^c$
#### 4: 1.4.9
Let $S$ be a given sample space and let $A_1, A_2, \dots$ be an infinite sequence
of events. For $n = 1,2, \dots$, let $B_n = \bigcup_{i=n}^\infty A_i$ and let
$C_n = \cap_{i=n}^\infty A_i$.
(a) Show that $B_1 \supset B_2 \supset \cdots$ and that $C_1 \subset C_2 \subset \cdots$.
(b) Show that an outcome in $S$ belongs to the event $\cap_{n=1}^\infty B_n$ if and only if it belongs to an infinite number of the events $A_1, A_2, \dots$.
(c) Show that an outcome in $S$ belongs to the event $\bigcup_{n=1}^\infty C_n$ if and only if it belongs to all the events $A_1, A_2, \dots$ except possibly a finite number of those events.
#### 5: 1.5.4
If the probability that student $A$ will fail a certain statistics examination is .5,
the probability that student $B$ will fail the examination is .2, and the probability that both
student $A$ and student $B$ fail the examination is .1, what is the probability that at least
one of these two students will fail the examination?
#### 6: 1.5.5
For the conditions of Exercise 4, what is the probability that neither student $A$ nor
student $B$ will fail the examination?
#### 7: 1.5.6
For the conditions of Exercise 4, what is the probability that exactly one of the two students will fail the
examination?
#### 8: R - job candidate
Barbara Smith is interviewing candidates to be her administrative assistant. As she interviews the candidates, she can determine the relative rank of the candidates
but not the true rank. Thus, if there are six candidates and their true rank is
6, 1, 4, 2, 3, 5, (where 1 is best) then after she had interviewed the first three candidates she would rank them 3, 1, 2. As she interviews each candidate,
she must either accept or reject the candidate. If she does not accept the
candidate after the interview, the candidate is lost to her. She wants to de-
cide on a strategy for deciding when to stop and accept a candidate that will
maximize the probability of getting the best candidate. Assume that there
are $n$ candidates and they arrive in a random rank order. [From Introduction to Probability by Grinstead and Snell]
(a) What is the probability that Barbara gets the best candidate if she interviews all of the candidates? What is it if she chooses the first candidate?
(b) Assume that Barbara decides to interview the first half of the candidates and then continue interviewing until getting a candidate better than any candidate seen so far. Show that she has a better than 25 percent chance of ending up with the best candidate.
(c) It can be shown that the best strategy is to pass over the first $k-1$ candidates where $k$ is the smallest integer for which
$$\frac{1}{k} + \frac{1}{k+1} + \cdots + \frac{1}{n-1} \leq 1$$
Using this strategy the probability of getting the best candidate is approximately 1/e.
Write a program to simulate Barbara Smith's interviewing if she uses this optimal strategy, using $n= 10$, and see if you can verify that
the probability of success is approximately 1/e.
Write a program to simulate Barbara Smith's interviewing if she uses this optimal strategy, using $n= 10$, and see if you can verify that the probability of success is approximately 1/e.
Hint: make sure you understand the code below. Then run the pieces separately to see what each one is doing. You'll have to repeat the entire things many times to estimate the relevant probability. (Look at HW1 for a reminder of how to run this entire thing in a for-loop. You will have two loops, I've only written the inside one.)
```{r}
n.cand = 6
n.pass = 3
# run the next 2 lines a few times to make sure you understand them
candid = sample(1:n.cand, n.cand, replace=FALSE)
candid # good to print at first so that you can see what is happening
# but maybe remove the line above before you turn in the HW so that there
# aren't a lot of numbers printing to the page without any context!
done=FALSE
for (i in (n.pass+1):n.cand){ # start the for-loop
if(candid[i] < min(candid[1:(i-1)])){ # another loop, this time under an "if" condition
hire = candid[i] # candid[i] is the ranked value in the i^{th} position
done=TRUE
break}
if(!done){hire=candid[n.cand]}
}
hire
# from HW do you remember how to find out if hire is the "best"?
# check to see if hire is 1.
# if you go through the loop a lot of times, you'll need to use
# the sum function to add up the number of TRUE, i.e., the number
# of times that hire is 1.
```