---
title: "Ch 3.2 Practice: Expected value"
author: "Put your name here"
output: pdf_document
---


# 1. Suppose that a hat contains slips of papers containing the numbers 1, 2, and 3. Two slips of paper are drawn at the same time and the numbers on the slips are multiplied together. Calculate the expected value of the product of the numbers on the slips of paper. Confirm your results using simulation.


* Theoretical expected value


* Confirm via simulation


\newpage

# 2. In the summer of 2020, the U.S. was considering *pooled testing* of COVID-19. This problem explores the math behind pooled testing. Since the availability of tests is limited, the testing center proposes the following pooled testing technique:

  1. Two samples are randomly selected and combined. The combined sample is tested.
  2. If the combined sample tests negative, then both people are assumed negative.
  3. If the combined sample tests positive, then both people need to be retested for the disease.
  
Suppose in a certain population, 5 percent of the people being tested for COVID-19 actually have COVID-19, and that individuals' test results are independent. Assume the test is 100% accurate, so if the person is negative they will always test negative. Let $X$ be the total number of tests that are run in order to test two randomly selected people.

## a.  What is the pmf of $X$? Explain in words or symbols & equations how you calculated your probabilities. 


## b. What is the theoretical expected value of $X$? Write your answer out in a sentence. 

## c. Now consider this process if three samples are combined. Let $Y$ be the total number of tests that are run in order to test three randomly selected people. If the pooled test is positive, then all three people need to be retested individually. **Use simulation to calculate the expected number of tests**

> Hint: The function `ifelse()` can be useful here. Try `ifelse(number_positive == 0, 1, 4)`. This returns a 1 if the value of `number_positive` is equal to 0, and 4 otherwise (if number_positive is not 0). 

## d. If your only concern is to minimize the expected number of tests given to the population, would you recommending pooling 2 or 3 samples together?



\newpage
# 3. How costly is it to fly? An airline charges the following baggage fees: $25 for the first bag and $35 for the second. Suppose 54% of passengers have no checked luggage, 34% have one piece of checked luggage and 12% have two pieces. We suppose a negligible portion of people check more than two bags.

## a. Define a random variable using a sentence. No R code here.  


## a. Build a probability model (pmf) for the revenue per passenger for the airline.



## b. Compute the theoretical average revenue per passenger. Confirm using simulation. 

* Theoretical



* Simulation



## c. Compute the corresponding standard deviation. Confirm using simulation. 

* Theoretical



* Simulation 


