---
title: "Homework 7"
author: "Insert Name"
date: "Math 141, Week 7"
output:
  pdf_document
graphics: yes
urlcolor: blue
---

```{r setup, include=FALSE}
# Do not modify this chunk.
knitr::opts_chunk$set(echo = T, message=FALSE, warning = FALSE, fig.align = "center")
library(knitr)
library(tidyverse)
library(moderndive)
```


**Due: 11:59pm, Friday March 11**

# Instructions
Work through the problems below  and submit this document as a knitted .pdf to the Math 141 S22 Wells Lecture [gradescope page](https://www.gradescope.com/courses/354598). 

**For each problem, put your solution between the bars of red stars.**



### Acknowledgements
If you work with a classmate, please write a note acknowledging this.

# Exercise 1

Suppose Nate's son Oliver loves the color fuchsia, and readily consumes any food imbued with this beautiful tint.  One company sells imitation M&M's, called W&W's, and colors some of them fuchsia.  Marketing materials from the producer claim that:

  - 25% of all W&W's produced are colored fuchsia, and 
  - Each bag of 100 W&W's can be regarded as a random sample of their W&W's.  


As advocates for justice in advertising and fuchsia in food, Nate and Oiver decide to test the company's claim regarding the proportion of fuchsia W&W's it produces.  
 
 
 
A.  Based on the information above, what **population** are Nate and Oliver interested in studying, and what are the relevant **parameters** are they are interested in?

**************************************************




**************************************************

B.  Suppose Nate and Oliver go to the store and buy a bag of W&W's, which contains 17 fuchsia W&W's. Explain why this *might* not be strong evidence that the makers of W&W's are making false claims about the distribution of fuchsia.

**************************************************




**************************************************

C. To support their case against the makers of W&W's, Nate and Oliver ask R to simulate the outcome of taking a supply of W&W's (of which 25% are fuchsia), and create 60 bags of 100 randomly chosen W&W's. The result are stored in the dataframe `WW`, where the variable `fuchsia` records the proportion of fuchsia W&W's in 60 simulated bags of 100 W&W's.



```{r, echo = FALSE}
set.seed(10)
n_bags <- 60
n_wws <- 100
fuchsia <- rbinom(n_bags, n_wws, 0.25)/n_wws

WW <- tibble(1:n_bags, fuchsia)

```

Use a histogram to visualize the distribution of the proportion of fuchsia W&W's in the 60 simulated bags.

**************************************************



**************************************************


D. Calculate the following summary statistics for the data set of sample proportions of fuchsia W&W's.

  - Mean
  - Standard Deviation
  - Minimum
  - First Quartile
  - Median
  - Third Quartile
  - Maximum

**************************************************



**************************************************

E. What proportion of the simulated bags contained 17 or fewer fuchsia W&W's?  

**************************************************



**************************************************

F. The `quantile(vector, proportion)` function in R outputs the number so that the given proportion of observations in the vector are less than or equal to that number. For example, for the vector x = (1,2,4,8,10), `quantile(x, .5)` outputs the number 4, since 4 is the median of this list of values. 

Use the `quantile` function to find numbers A and B so that only 2.5% of all bags have proportions of fuchsia W&Ws less than or equal to A, and only 97.5% of all bags have proportions of fuchsia W&Ws less than or equal to B. (In other words, 95% of all bags have proportions of fuchsia W&Ws between A and B)

**************************************************



**************************************************

G. Based on your answers to the previous questions, does it seem like Oliver's bag that contained only 17 fuchsia W&W's presents strong evidence against the claim that 25% of all W&W's produced are colored fuchsia? Explain.

**************************************************



**************************************************
