---
title: "SML201 Precept 8, Spring 2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
### Problem 1
Suppose that $X\sim\mathcal{N}(2, 10^2)$. We sample the variable $X$ once (i.e., we obtain a sample from the distribution $\mathcal{N}(2, 10^2)$). In this problem, you will be computing the same quantity in four different ways. You should expect to get roughly the same answer every time.
### Problem 1(a)
Write R code to obtain $P(2.1 < X < 3.1)$. Use `pnorm`.
### Problem 1(b)
Write R code to obtain $P(2.1 < X < 3.1)$. Use `pnorm(..., ,mean = 0, sd = 1)`.
### Problem 1(c)
Write R code to obtain $P(2.1 < X < 3.1)$. Use `rnorm`. (And not `pnorm`.)
### Problem 1(d)
Write R code to obtain $P(2.1 < X < 3.1)$. Use `rnorm(..., mean = 0, sd = 1)`
### Problem 2
Suppose 65% of Princeton students like Wawa better than World Coffee. We selected a random sample of 100 students, and asked them which they prefer. What is the probability that more than 78 students said "Wawa"?
#### Problem 2(a)
Answer the question using `pbinom`.
#### Problem 2(b)
Answer the question using `pnorm`. Use the normal approximation to the Binomial distribution (recall: the mean is $n\times prob$ and the variance is $n\times prob\times (1-prob)$).
(Note: you shouldn't expect an exact match between 2(a) and 2(b) because of the lack of continnuity correction. You can try obtaining an exact match by varying the value of the `q`).
### Problem 3
Suppose 100 Princeton students we asked whether Harvard or Stanford is the worse online institution of higher learning. 60 students said that Stanford is worse. Compute the p-value for the null hypothesis that Princeton students think that Harvard and Stanford are equally bad, on average. What can you conclude?
### Problem 4
Answer Problem 2 using only `rnorm(..., mean = 0, sd = 1)`