---
title: "A05 Basic Probability (166 points)"
author: "TYPE YOUR NAME HERE"
date: "TYPE DATE HERE"
format: docx
editor: visual
---

```{r}
#| message: false
#| warning: false
#| echo: false
library(tidyverse)
```

## Instructions

Complete each exercise either in this qmd file or on paper. Include your name as the author and the date completed in the YAML code at the top of this file, and replace the first sentence in the Acknowledgements section as directed. Any parts completed on paper should either (a) be handed to David Housman, (b) placed in SC 117, or (c) scanned into a pdf file. This qmd file should be rendered to an html, docx, or pdf file. Zip together all relevant files: Rproj, qmd, rendered file, any data or image files, and (optionally) the pdf file containing your answers completed on paper. Upload the zip file in Moodle. Points will be taken off if these instructions are not followed.

## Acknowledgements

Replace this sentence with either (1) an acknowledgment of any person who gave you assistance and/or any resource that was used, or (2) a statement that you did not use any outside assistance.

By submitting this assignment, the author attests to abiding by the *Collaboration and Academic Integrity* policy stated in the course syllabus.

## Exercise 1 (68 points)

Consider the experiment *roll a four-sided die and six-side die* and the random variables *sum* and *minimum*.

a.  (20 points) Run the experiment at least 60 times and record the results in a *csv* file. You may complete this exercise in a group of up to three students who share the file with each other. State here who ran the experiment with you.

b.  (4 points) Read the experimental run data and store in a tibble.

c.  (8 points) Define a function that simulates the experiment, use that function to obtain 150 simulations of the experiment, and store the simulations in a tibble with appropriate column names.

d.  (4 points) Obtain data that matches the theoretical distribution (e.g., contains each possible outcome of the experiment), and store in a tibble with appropriate column names.

e.  (4 points) Place the three previously created tibbles into a single tibble `dice` with an identifying categorical variable.

f.  (8 points) Add the columns *sum* and *minimum* to the `dice` tibble.

g.  (4 points) Obtain a random selection of eight rows of `dice`. Check that your code appears to be working correctly.

h.  (8 points) Obtain a violin plot that compares the distribution of *sum* as a function of the three types of dice rolls. What is your conclusion?

i.  (8 points) Obtain a faceted histogram that compares the distribution of *minimum* as a function of the three types of dice rolls. What is your conclusion?

## Exercise 2 (16 points)

Explain from the viewpoint of a theoretician, frequentist, subjectivist, and mathematician the meaning of the following sentence: “When drawing a single ball from an urn containing two purple and three white balls, the probability that the ball is purple is 2/5.”

## Exercise 3 (36 points)

Based on Ledolter exercises 2.1-4, 5, 8, 9. For each of the following theoretical probability computations, show the process used and the answer obtained.

a.  A person has purchased 5 of 1,000 tickets sold in a certain raffle. To determine the 10 prizewinners, 10 tickets are drawn at random and without replacement. Compute the probability that this person wins *exactly* one prize.

b.  For the situation in (a), compute the probability that he wins at least one prize.

c.  A bowl contains 20 chips, of which 9 are red, 8 are white, and 3 are blue. Six chips are taken at random and without replacement. Find the probability that each of the 6 chips is red.

d.  For the situation in (c), find the probability that there are 3 red, 2 white, and 1 blue chips among the six chips selected.

e.  For the situation in (c), find the probability that none of the 6 chips selected is blue.

f.  For the situation in (c), find the probability that there is at least 1 white and at least 1 blue chip among the 6 selected.

g.  If the sample space $S = A \cup B$, $P(A) = 0.7$, and $P(B) = 0.3$, find $P(A \cap B)$.

h.  If $P(A) = 0.4$, $P(B) = 0.5$, and $P(A \cup B) = 0.7$, find $P(A \cap B)$.

i.  If $P(A) = 0.4$, $P(B) = 0.5$, and $P(A \cup B) = 0.7$, find $P(A' \cap B')$.

## Exercise 4 (16 points)

Create and run computer simulations to estimate the probabilities described in #3d and #3f.

## Exercise 5 (10 points)

a.  (7 points) Simulate flipping a fair coin 200 times, find the cumulative fraction of heads after each flip, and display the cumulative fractions as a time series.

b.  (3 points) Write a precise conclusion.

## Exercise 6 (20 points)

Consider the experiment *flip a fair coin 100 times* and the variable *the number of heads*.

a.  (8 points) Obtain 1000 simulations of this experiment.

b.  (4 points) Obtain a histogram for the number of heads.

c.  (4 points) Obtain the 95% coverage interval for the number of heads.

d.  (4 points) Write precise conclusions in the context of the original experiment.
