```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

**Due Date:** Friday 11/05/2021, 11:59 PM

**Instructions:** <br>
 
 * Please provide complete answers/solutions for each question/problem. 
 
 * **If it involves mathematical computations, please provide your reasoning and/or detailed solutions.**
 
 * There are two ways you can write your answers, a: by handwriting (either physically or digitally), or b: by typing on a template document with file type options, Word or RMarkdown, which can be downloaded from the [course website](https://reed-statistics.github.io/math141-fall2021/homeworks.html){target="_blank"}.
 
 * If you had handwritten your answers/solutions on a physical paper, make sure to label it properly and please scan your document using a scanner app for convenience. Suggestions: (1) ["Tiny Scanner" for Android](https://play.google.com/store/apps/details?id=com.appxy.tinyscanner&hl=en_US&gl=US){target="_blank"} or (2) ["Scanner App" for iOS](https://apps.apple.com/us/app/scanner-app-scan-pdf-document/id595563753){target="_blank"}.
 
 * If a problem asks you to show your R code, R outputs, or R plots, please provide them as additional pages into your current homework pdf while labeling them properly. This means that, **if you have handwritten your homework solutions and saved it as pdf, you would need to merge the separate pdf which contains your R code, R outputs, or R plots. Note that all of the problems that require R does not require you to show your R code - unless the problem specifically says so.**
 
 * If you have questions or concerns, please feel free to ask the instructor.
 
 * **Please save your work as one pdf file, don't put your name in any part of the document, and submit it to the Gradescope page for this course. Your document upload will correspond to your name automatically in Gradescope.**

```{r echo=FALSE, message=FALSE}
# load libraries
library(openintro)
library(tidyverse)
library(dplyr)
```

\newpage

## I. Basic Probability

1. **Fair Coin I.** We flip a fair coin two times. The flips are independent. Remember, a fair coin lands on heads $H$ with probability $\frac{1}{2}$ and tails $T$ with probability $\frac{1}{2}$. If the outcomes are the same (HH or TT) we win; otherwise we lose.
    
  * Let $A$ be the event when the first coin comes up heads.
    
  * Let $B$ be the event when the second coin comes up heads.
  
  * Let $C$ be the event when both flips are the same.
  
    Remember, $A \cap B$ is the set intersection operation and $A \cup B$ is the set union operation.

    What is $P(A \cap B \cap C)$?

2. **Fair Coin II.** We flip a fair coin $n=100$ times where $P(H) = \frac{1}{2}$ and $P(T) = \frac{1}{2}$. Answer the following questions. You can use R functions here to compute the probabilities but you need to write out the mathematical notations.
    
    a. What is the probability that we observe at least 35 Tails? Include a plot of the PMF and shade the appropriate regions.
    b. What is the probability that we observe at 35 to 50 Tails? Include a plot of the PMF and shade the appropriate regions.

  3. **\textcolor{ForestGreen}{[BONUS PROBLEM]} Rolling a six-sided die.** Prove the following statements. Explain your reasoning. In class, we discussed about answering the question "what is the probability that of getting a 6 for the first time on the $n$th roll?". We determined that the probability function for computing the probability is given by 
  $$P(X = n) = \frac{5^{n-1}}{6^n}$$
where $X$ is a discrete random variable of the number of rolls until getting a 6, meaning the number of failures in a sequence of Bernoulli trials before success occurs. The above function is called the geometric distribution function.
      
      a. Statement 1: $\sum_{x=1}^{\infty} P(x) = 1$
      b. Statement 2: $E[X] = \sum_{x=1}^{\infty} x P(x) = 6$
      c. Statement 2 is the expected value or the expected number of rolls until you get a 6 for the first time. Plot the function and highlight the expected value within the plot - make sure to label your axes properly. Describe what you observed in the plot. What is the $P(X \ge 6)$? Explain this probability in context and highlight the region in the plot. Note: In R, you have used `dbinom` for the binomial PMF while you can use `dgeom` for the geometric PMF.
      
4. **Marbles in a Jar.** There are 7 red marbles and 3 blue ones in a jar. We randomly take out marbles from the jar without replacement, which means that we do not put any marbles back into the jar after they are taken out.

    a. We take out 3 marbles. Let $X$ be the number of red marbles among the three. Does $X$ have a binomial distribution? Why or why not?
    b. Let $Y$ be the number of marbles we have to take out until we get the first blue one. Does $Y$ have a geometric distribution? Why or why not?
    
5. **SAT vs ACT.** SAT scores follow a nearly normal distribution with a mean of 1500 points and a standard deviation of 300 points. ACT scores also follow a nearly normal distribution with mean of 21 points and a standard deviation of 5 points. Suppose Saucy scored 1300 points on their SAT and Sassy scored 31 points on their ACT.

    a. Draw a standardized normal distribution plot for Saucy and highlight the z-score corresponding to their SAT score of 1300.
    b. Draw a standardized normal distribution plot for Sassy and highlight the z-score corresponding to their ACT score of 31.  Who performed better - Saucy or Sassy?

\newpage

## II. Conditional Probability

1. **Emotional Valence.** Suppose that you have 10 words in a sequence with 5 positive words and 5 negative words. You randomly shuffle them and place them in a sequence.

    Let $A$ be the event that there is at least 1 positive word in the top three words of the sequence.
    
    What is $P(A)$?

2. **Language Class.** An elementary school is offering 3 language classes: Spanish, French and German. The classes are open to any of the 100 students in the school. Moreover, none of the classes overlap so it is possible for students to take 0, 1, 2, or all 3 language classes. There are 28 students in the Spanish class, 26 in the French class and 16 in the German class. There are 12 students that are in both Spanish and French, 4 that are in both Spanish and German, and 6 that are in both French and German. In addition, there are 2 students taking all 3 classes.

    a. If a student is chosen at random, what is the probability they are not in any of the language classes?
    b. If a student is chosen randomly, what is the probability that they are taking exactly 1 language class.
    c. If 2 students are chosen randomly, what is the probability that at least 1 is taking a language class?

3. **Probability Urns.** An urn contains 6 red balls and 8 green balls. Two balls are drawn one after the other. 

    a. What is the probability that the second ball is red?
    b. What is the probability that the first ball is green?
  
4. **Probability Jars.** Suppose that three jars contain colored balls as described in the table below.

    Note: This question has two parts, between the two parts assume that all balls are returned to their original jar. The jars in each case are chosen independently.

    a. One jar is chosen at random and a single ball is selected. If the ball is white, what is the probability that it came from the 2nd jar?
    b. One jar is chosen at random and two balls are selected. If both balls are blue, what is the probability it came from the 2nd jar? Explain why.

|       | Red | White | Blue |
|-------|-----|-------|------|
| Jar 1 | 3   | 3     | 1    |
| Jar 2 | 4   | 2     | 2    |
| Jar 3 | 1   | 3     | 6    |

5. **Flu Season.** Assume that 1\% of California's population will test positive for flu this week. Assume that the false positive rate is around 1\%. Assume we test a random sample of people and one of them tests positive. What is the probability that the individual has the flu? Let event $A$ be the positive test result, and event $B$ be the flu.

    a. What is $P(A)$ and $P(B)$?
    b. What is $P(B|A)$?

\newpage
