DATA 8 Foundations of Data Science Midterm
Summer 2021 Solutions
INSTRUCTIONS
For questions with circular bubbles, you should fill in exactly one choice.
You must choose either this option
Or this one, but not both!
For questions with square checkboxes, you may fill in multiple choices.
⇤ You could select this choice.
⇤ You could select this one too!
For fill-in-the-blank coding questions, you can put anything inside the blanks, including
commas,parentheses, and periods.
Preliminaries
You can complete these questions before the exam starts.
(i) What is your full name?
(ii) What is your Student ID number?
(iii) The Berkeley Honor Code states: “As a member of the UC Berkeley community, I act with honesty,
integrity, and respect for others.” Do you agree to follow the honor code on this exam?
Yes
No
,This page intentionally left blank
Page 2
, Exam generated for <EMAILADDRESS> 3
1. (15 points) Fun Report
Tyler hosts a weekly podcast called “The Fun Report”. At the beginning of each episode, Tyler tells listeners if
he is having fun or not. Coley thinks that episodes of the podcast are longer when Tyler is not having fun.
Coley listened to the most recent 30 episodes of the podcast and recorded whether Tyler was having fun or not,
and the length of each episode, in minutes, in the table fun.
Episode Having Fun Length
54 Yes 118
53 No 145
52 No 168
{27 rows omitted}
There are an equal number of episodes where Tyler had fun as where he didn’t have fun.
(a) (2 pt) Which of the following lines of code could Coley use to explore his hypothesis in the sample he
collected? (Select all that apply)
⌅ fun.group("Having Fun", np.average).barh("Having Fun", "Length average")
⌅ fun.hist("Length", group="Having Fun")
2 fun.plot("Episode", "Length")
2 fun.scatter("Episode", "Length")
For the following questions, your test statistic may not involve taking the average (or mean) of any data.
Your answers must be exactly one sentence long. If your response is longer than one sentence, it will
receive 0 credit.
(b) i. (2 pt) Write a null hypothesis Coley can use to test his hypothesis.
Episodes where Tyler is having fun have lengths that are drawn from the same
underlying distribution as episodes where Tyler is not having fun.
ii. (2 pt) Write an alternative hypothesis Coley can use to test his hypothesis.
The lengths of episodes where Tyler is not having fun are drawn from a distri-
bution with a larger (parameter, depends on your statistic, an example could be
median) than the distribution of lengths episodes where Tyler is having fun are
drawn from.
iii. (2 pt) Write a test statistic Coley can use to test his hypothesis. As a reminder, your test statistic
may not involve taking the average (or mean) of any data.
Your answer needs to compare both the A and B group, and should have extreme
values point to the alternative hypothesis. Some examples include:
• The median length of episodes where Tyler is having fun, minus the median
length of episodes where Tyler is not having fun
• Differences in percentiles (including max or min)
• Difference in sum of the same number of episodes for each group
• Anything involving ranking values
Summer 2021 Solutions
INSTRUCTIONS
For questions with circular bubbles, you should fill in exactly one choice.
You must choose either this option
Or this one, but not both!
For questions with square checkboxes, you may fill in multiple choices.
⇤ You could select this choice.
⇤ You could select this one too!
For fill-in-the-blank coding questions, you can put anything inside the blanks, including
commas,parentheses, and periods.
Preliminaries
You can complete these questions before the exam starts.
(i) What is your full name?
(ii) What is your Student ID number?
(iii) The Berkeley Honor Code states: “As a member of the UC Berkeley community, I act with honesty,
integrity, and respect for others.” Do you agree to follow the honor code on this exam?
Yes
No
,This page intentionally left blank
Page 2
, Exam generated for <EMAILADDRESS> 3
1. (15 points) Fun Report
Tyler hosts a weekly podcast called “The Fun Report”. At the beginning of each episode, Tyler tells listeners if
he is having fun or not. Coley thinks that episodes of the podcast are longer when Tyler is not having fun.
Coley listened to the most recent 30 episodes of the podcast and recorded whether Tyler was having fun or not,
and the length of each episode, in minutes, in the table fun.
Episode Having Fun Length
54 Yes 118
53 No 145
52 No 168
{27 rows omitted}
There are an equal number of episodes where Tyler had fun as where he didn’t have fun.
(a) (2 pt) Which of the following lines of code could Coley use to explore his hypothesis in the sample he
collected? (Select all that apply)
⌅ fun.group("Having Fun", np.average).barh("Having Fun", "Length average")
⌅ fun.hist("Length", group="Having Fun")
2 fun.plot("Episode", "Length")
2 fun.scatter("Episode", "Length")
For the following questions, your test statistic may not involve taking the average (or mean) of any data.
Your answers must be exactly one sentence long. If your response is longer than one sentence, it will
receive 0 credit.
(b) i. (2 pt) Write a null hypothesis Coley can use to test his hypothesis.
Episodes where Tyler is having fun have lengths that are drawn from the same
underlying distribution as episodes where Tyler is not having fun.
ii. (2 pt) Write an alternative hypothesis Coley can use to test his hypothesis.
The lengths of episodes where Tyler is not having fun are drawn from a distri-
bution with a larger (parameter, depends on your statistic, an example could be
median) than the distribution of lengths episodes where Tyler is having fun are
drawn from.
iii. (2 pt) Write a test statistic Coley can use to test his hypothesis. As a reminder, your test statistic
may not involve taking the average (or mean) of any data.
Your answer needs to compare both the A and B group, and should have extreme
values point to the alternative hypothesis. Some examples include:
• The median length of episodes where Tyler is having fun, minus the median
length of episodes where Tyler is not having fun
• Differences in percentiles (including max or min)
• Difference in sum of the same number of episodes for each group
• Anything involving ranking values