
---
title: "Problem Set 08"
author: "WRITE YOUR NAME HERE"
date: "Due Friday, April 14, 2017"
output:
  html_document:
    theme: cosmo
    highlight: tango
    df_print: kable
---


Load necessary packages:

```{r, message=FALSE, echo=TRUE}
library(ggplot2)
library(dplyr)
library(mosaic)
library(knitr)

# Set random number generator seed value:
set.seed(76)
```



## Question 1:

You are going to compute via simulation and not via mathematical formulas, the 
**probability distribution** of all possible sums of two die rolls: for all 
possible sums of rolling two dice (x=2, x=3, ..., x=12), we compute
Probability(sum of rolling two dice = x).

1. Write code that will simulate die rolls and manipulate the output so that
you end up with a data frame `probs` with 11 rows and 2 columns:
    + `sum`: each value of the possible sum of rolling two dice
    + `probability`: the observed probability of each value of `sum`
1. Note even though `sum` is a numerical variable, we'll treat it as a 
categorical variable by using the `factor()` command and using a bar chart. It 
looks cleaner this way.

```{r}
# Write your code to create the data frame probs here:



# After you've created prob, uncomment these three lines so that your plot will
# show up:

# ggplot(probs, aes(x=factor(sum), y=probability)) +
#  geom_bar(stat="identity") +
#  labs(x="Sum", y="Probability of Sum", title="Outcomes of Rolling Two Dice")
```




## Question 2:

(From OpenIntro Statistics 3rd Edition Exercise 3.20) In the following situations
assume that half of the specified population is male and the other half is
female:

a) Suppose you're sampling from a room with 10 people. What is the probability
of sampling two females in a row when sampling with replacement? What is the
probability when sampling without replacement?
b) Now suppose you're sampling from a stadium with 10,000 people. What is the
probability of sampling two females in a row when sampling with replacement?
What is the probability when sampling without replacement?
c) Compare sampling with and without replacement in the 10 person room vs the
10,000 stadium. Why might these results matter in a survey setting?

We can either

* Compute theses probabilities using mathematical formulae OR
* Compute the probabilities using R's sampling/simulation capabilities via `mosaic`.

You'll be doing the latter.


#### Parts a) and b)

**Starter Code**: We define a `room` and `stadium`, both half female, but with 
populations of size `n=10` and `n=10000`. Let `1` represent a female and `0` 
represent a male, so that to count the number of females we need to only `sum()`
a series of `0`'s and `1`'s.

```{r}
room <- rep(c(1, 0), each=5)
stadium <- rep(c(1, 0), each=5000)

# Write your code here:

```

Fill in the table with the results from your simulations in the code block below

Sampling Type        | Room   | Stadium
-------------------- | -------| -------
With replacement     | 0.000  | 0.000
Without replacement  | 0.000  | 0.000


#### Part c)



