library(tidyverse)
set.seed(4444) # so you get the same "random" spins each time you render
reps <- 10000 # number of simulated spinsHomework 2
BSTA 550
Assignment information
Directions
Please turn in this homework on Brightspace. Please submit your homework as a pdf or html file. You can type your work in this file and render it, or submit a single file with photos of your written work or any other method that can be turned into a pdf. Please let me know if you prefer to submit a physical copy, we can arrange for a physical “turn in” during Monday’s class.
Get the .qmd file: You can download this homework as a .qmd file from GitHub. On that page, click the download button (“Download raw file”) near the top right of the file.
You must show all of your work to receive credit.
Extra problems do not need to be turned in!!
If you are editing this .qmd file, then you will see a section right below the YAML called “HOW TO USE THIS FILE.” Please follow those instructions to make sure you are not deleting essential parts of this file. When you render, that section will not show up.
Using AI is not required in this class. If you did use an AI tool (ChatGPT, Claude, Copilot, Gemini, an RStudio assistant, etc.) on this homework, add a brief AI Use Statement at the very top of your submission. Include:
- Which tool(s) you used
- What for (a sentence or two, with question numbers)
- Where it contributed to any written interpretations (if at all)
- You do NOT need to link your conversation.
For example:
AI Use Statement: Claude was used to explain an error message in Question 3. All statistical reasoning, code review, and conclusions are my own.
OR
AI Use Statement: AI was not used in this assignment.
Before using AI, check the table of allowed uses in the Generative AI Policy. For homework, AI can help you understand (explain an error or a concept, check an answer you already worked out, give feedback on your own writing), but it should not do the problem for you. A half-finished answer that shows your thinking is always better than a polished one from AI!
Questions
1. Health conditions in US adults
Suppose the following are the percentage of US adults with the following conditions:
- \(A\): Hypertension 33%
- \(B\): Diabetes 9%
- \(C\): Metabolic syndrome 24%
- \(A\) or \(B\): 39%
- \(A\) or \(C\): 45%
- \(B\) or \(C\): 28%
- \(A\) or \(B\) or \(C\): 48%
Part a
Make a Venn diagram of the 3 conditions labeling the percentage (or probability) for ALL of the 8 “sections”. Hint: Start from the last condition and work your way up!
Answer:
Part b
For each of the following (1. - 7. below), (\(i\)) write out the event using unions, intersections, and/or complements of the events \(A\), \(B\), and \(C\) (this is NOT finding the probability, that’s in \(ii\)); (\(ii\)) find the probability of the event; and (\(iii\)) write a sentence explaining what the probability is of in terms of the context of the problem.
- \(\mathbb{P}\)(event at least one of the 3)
- \(\mathbb{P}\)(event none)
- \(\mathbb{P}\)(event \(A\) only)
- \(\mathbb{P}\)(event exactly one)
- \(\mathbb{P}\)(event \(A\) and \(B\))
- \(\mathbb{P}\)(event \(A\) and \(B\) but not \(C\))
- \(\mathbb{P}\)(event all 3)
Answer:
- At least one of the 3
- Event:
- Probability:
- Sentence:
- None
- Event:
- Probability:
- Sentence:
- \(A\) only
- Event:
- Probability:
- Sentence:
- Exactly one
- Event:
- Probability:
- Sentence:
- \(A\) and \(B\)
- Event:
- Probability:
- Sentence:
- \(A\) and \(B\) but not \(C\)
- Event:
- Probability:
- Sentence:
- All 3
- Event:
- Probability:
- Sentence:
2. Guessing on an exam
While taking a probability exam, you come to three questions that you have no clue how to answer. You would have known the answers if you had taken the time to study the night before instead of going to a party, but you did not make a good life choice, and you vow to never party on a school night again if you fail this exam. Each question on the exam is multiple choice with the correct answer being either a, b, c, d, or e. (Your guesses are independent.) What is the probability that:
Part a
you randomly guess the right answer to all three questions?
Answer:
Part b
you randomly guess the right answer to none of the three questions?
Answer:
Part c
you randomly guess the right answer to exactly one of the three questions?
Answer:
Part d
you randomly guess the right answer to exactly two of the three questions?
Answer:
Part e
Do the probabilities in parts a–d sum to 1?
Answer:
3. Pairwise vs. mutual independence
Recall from class that we defined events \(A\), \(B\), and \(C\) to be mutually independent if both (1) and (2) below hold. The point of this exercise is to show that \((1)\nRightarrow (2)\) and \((2)\nRightarrow (1).\)
\[\begin{array}{cl} (1) & \mathbb{P}(A\cap B)=\mathbb{P}(A)\,\mathbb{P}(B) \\ & \mathbb{P}(A\cap C)=\mathbb{P}(A)\,\mathbb{P}(C) \\ & \mathbb{P}(B\cap C)=\mathbb{P}(B)\,\mathbb{P}(C) \\[6pt] (2) & \mathbb{P}(A\cap B\cap C)=\mathbb{P}(A)\,\mathbb{P}(B)\,\mathbb{P}(C) \end{array}\]
Part a
Suppose two different fair dice are rolled. Let events \(A\), \(B\), and \(C\) be defined in the following way:
\[\begin{array}{cl} A: & \text{Roll a total of 7} \\ B: & \text{First die is a 6} \\ C: & \text{Second die is a 2} \end{array}\]
Show that condition \((1)\) holds, but that condition \((2)\) does not.
Answer:
Part b
Suppose two different fair dice are rolled. Let events \(A\), \(B\), and \(C\) be defined in the following way:
\[\begin{array}{cl} A: & \text{Roll a 1 or 2 on the first die} \\ B: & \text{Roll a 3, 4, or 5 on the second die} \\ C: & \text{Roll a total of 4, 11, or 12} \end{array}\]
Show that condition \((2)\) holds, but that condition \((1)\) does not.
Answer:
4. Parity of spinning
A spinner has the left side (numbers 1, 2, 3, 4, and 5) colored red and the right side colored white (numbers 6, 7, 8, and 9), with all numbers equally likely.
Part a
What is the probability the spinner lands on an odd number?
Answer:
Part b
Given that the spinner landed on an odd number, what is the chance the spinner landed on a white number?
Answer:
Part c
Given that the spinner landed on a white number, what is the chance it landed on an odd number?
Answer:
Part d
Check your answers to Parts a–c by simulating 10,000 spins in R. Use the four steps of a simulation from Lesson 2. The two dice simulations in Lesson 4 (Examples 1 and 3) are good models to follow.
Step 1: Set up. This chunk is done for you. Run it before the others.
Step 2: Simulate. Make a table with one row per simulation, and add a column called spin with a random number from 1 to 9 in each row.
- Hint:
expand_grid(sim = 1:reps)makes one row per simulation. Thenmutate()andsample(1:9, n(), replace = TRUE)give every row one spin.
Answer:
# Your code hereStep 3: Define the events. Add two TRUE/FALSE columns to your table:
odd, which isTRUEwhen the spin is odd. Hint:spin %in% c(1, 3, 5, 7, 9)asks “is the spin one of these numbers?”white, which isTRUEwhen the spin is on the white side (6, 7, 8, or 9).
Answer:
# Your code hereStep 4: Summarize. Approximate the three probabilities from Parts a–c.
- Part a: the proportion of spins that are odd. Use
mean()on theoddcolumn. - Parts b and c: “given” means we only keep the spins where the given event happened. Use
filter()to keep those rows, then take themean()of the other event (like the second way in Lesson 4, Example 3).
Answer:
# Your code hereAre your simulated probabilities close to your answers in Parts a–c? (They do not need to match exactly!)
Answer:
6. Raffle tickets
There are 30 raffle tickets in a bowl. Three winning tickets will be selected. Each ticket can win at most one prize. How many ways can the prizes be distributed if the following additional information is known?
Part a
All 3 winners receive goldfish (the goldfish are indistinguishable).
Answer:
Part b
The 1st winner receives a car, the 2nd a bicycle, and the 3rd a goldfish.
Answer:
7. Defective pills
A new drug is packaged to contain 30 pills in a bottle. Suppose that 98% of all bottles contain no defective pills, 1.5% contain one defective pill, and 0.5% contain two defective pills. Two pills from a bottle are randomly selected and tested. What is the probability that there are 2 defective pills in the bottle given that exactly one of the two tested pills is defective?
Answer:
Extra problems
You do NOT need to complete the extra problems!
1. Weather
The weather on any given day can either be sunny, cloudy, or partially cloudy. Each day is also classified as dry or rainy. The probability of a sunny day is 0.48, and the probability of a cloudy day is 0.39. The probability of having a sunny and dry day is 0.48. The probability of a cloudy and dry day is 0.14. The probability of a partially cloudy and dry day is 0.09.
Part a
Find the probability of a dry day.
Part b
Find the probability of a rainy day.
Part c
Find the probability of a sunny day given that it is a dry day.
Part d
Find the probability of a dry day given that it is a sunny day.
Part e
Find the probability of a cloudy day given that it is a rainy day.
Part f
Find the probability that it is a rainy day given that it is a cloudy day.
2. Coins
Judith has a penny, nickel, dime, and quarter in her pocket. So does Joe. They both reach into their pockets and choose a coin (all four coins are equally likely to be selected). Let \(X\) be the larger value (in cents) of the coins selected by Judith and Joe. For reference, the penny is 1 cent, nickel is 5 cents, dime is 10 cents, and quarter is 25 cents.
Part a
How many possible combinations are there for the pair of Judith’s and Joe’s selected coins? (Hint: we know to whom each coin belongs)
Part b
Define the sample space for \(X\) in this experiment.
Part c
Find the probability for each possible value of \(X\).
Part d
Find the probability of the event that Judith’s coin is worth more than Joe’s.
3. Smelling Parkinson’s disease
Read the Washington Post article The amazing woman who can smell Parkinson’s disease - before symptoms appear (http://www.washingtonpost.com/news/morning-mix/wp/2015/10/23/scottish-woman-detects-a-musky-smell-that-could-radically-improve-how-parkinsons-disease-is-diagnosed/)
Assuming Joy Milne does not have the ability to detect Parkinson’s disease via smell, answer the following questions:
Part a
What is the probability of her correctly detecting Parkinson’s by smelling one t-shirt?
Part b
What is the probability of her correctly detecting Parkinson’s in 12 out of 12 t-shirts?
4. Calculus review
Part a
\[\int_0^yc(x+y)dx\]
Part b
\[\frac{d}{dx}\bigg(\frac{4}{9}x^2y^2+\frac{5}{9}xy^4\bigg)\]
Part c
\[\frac{d}{dy}\bigg(\frac{4}{9}x^2y^2+\frac{5}{9}xy^4\bigg)\]
Part d
\[\int_0^y2e^{-x}e^{-y}dx\]
Part e
\[\int_0^\infty xye^{-(x+y)}dy\]
Part f
\[\int_x^{2x} 2e^{-(x+3y)}dy\]
Part g
Find the area of the region bounded by the graphs of \(f(x)=2-x^2\) and \(g(x)=x\) by integrating with respect to \(x\).
Part h
Find the area of the region bounded by the graphs of \(f(x)=2-x^2\) and \(g(x)=x\) by integrating with respect to \(y\).
Part i
Find the area of the region bounded by the graphs of \(x=3-y^2\) and \(y=x-1\) by integrating with respect to \(x\).
Part j
Find the area of the region bounded by the graphs of \(x=3-y^2\) and \(y=x-1\) by integrating with respect to \(y\).