library(tidyverse)
library(purrrfect)
RUBRIC
| Process (30%) |
All code follows structure demonstrated in course notes. For each
question, the entire simulation data set is created with one series of
pipes. |
Code partially follows template demonstrated in course notes. |
Code minimally follows template demonstrated in course notes. |
| Correctness (20%) |
All code produces correct output. |
Code provides partially correct output. |
Code has many bugs and/or does not produce the correct output. |
- An aquarium has 30 fish, of which 20 are infected with tapeworm.
Suppose 10 fish are sampled at random from this aquarium. Let \(Y\) represent the number of sampled fish
that are infected.
- Use
purrrfect::replicate() and map
functions to simulate 10,000 realizations of \(Y\).
- Verify that \(Y\) follows a
hypergeometric distribution by creating appropriate plots.
- Suppose that \(M\), the number of
cars driving through a Culver’s drive-thru, follows a Poisson
distribution with on average \(\lambda\) cars per hour. Given \(M=m\), the number of these cars that will
order the walleye sandwich follows a \(BIN(m,
p)\) distribution. Verify via simulation study for \(\lambda \in\{20, 30, 50\}\) and \(p\in \{0.2, 0.4, 0.6\}\) that \(Y \sim POI(\lambda p)\) by simulating
10,000 “drive-thru-hours” for each \(\{\lambda, p\}\) combinations and verifying
graphically that the empirical CDF of the number of cars ordering the
walleye sandwich well-approximates the analytic CDF.