← return to practice.dsc10.com


Lecture 19 — Collected Practice Questions

Topics: Hypothesis testing.

Below are practice problems tagged for Lecture 19 (rendered directly from the original exam/quiz sources). By default, problems are sorted from easiest to hardest by average score; problems without a score are listed last.


Source: Question 2 from Fall 2024 Quiz 4

Problem 1

Consider the following pair of hypotheses:

Let C_9 be the proportion of "Comedy" movies with a rating above 9 and let A_9 be the proportion of "Action" movies with a rating above 9. Which of the following are valid test statistics to test these hypotheses? Select all that apply.

Answer: C_9 - A_9 and A_9 - C_9

The hypotheses compare two proportions, and the alternative has a direction (“Comedy is greater”). So a valid test statistic needs to do two things:

  1. Compare C_9 and A_9 to each other. C_9 - 0.5 and A_9 - 0.5 each look at only one proportion. A_9 \cdot C_9 and A_9 + C_9 use both, but they don’t measure how far apart the two are. For example, (0.3, 0.5) and (0.5, 0.3) have the same sum and the same product.
  2. Tell us which proportion is bigger. |A_9 - C_9| and |C_9 - A_9| measure how far apart the two proportions are, but they can’t tell whether Comedy or Action is higher. They’d fit a two-sided alternative (“the proportions are different”), not this one.

C_9 - A_9 and A_9 - C_9 satisfy both. With C_9 - A_9, large positive values point toward the alternative. With A_9 - C_9, large negative values do. Either one works, as long as we calculate the p-value in the matching direction.


Difficulty: ⭐️⭐️

The average score on this problem was 82%.


Source: Question 5 from Winter 2026 Quiz 4

Problem 2

Jeffrey frantically defends himself by claiming that the true proportion of his submissions that scored below 70 is really 0.20 — not nearly as bad as it looks! To test his claim, Detective Peter constructs a 95% confidence interval and gets [0.14, 0.40].


Problem 2.1

Using this confidence interval, at the 5% significance level, what decision should we make with respect to Jeffrey’s claim? Select all that are correct.

Answer: Fail to reject

The value 0.20 under the null (Jeffrey’s claimed proportion) lies inside the 95% confidence interval, so the data are not inconsistent with that proportion at the 5% level — we do not reject Jeffrey’s claim. We do not “accept” the null in the formal hypothesis-testing sense; “fail to reject” is the appropriate language.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 64%.


Problem 2.2

Which of the following best explains why we reach that conclusion?

Answer: Because 0.20 lies inside the confidence interval, the data are consistent with Jeffrey’s claim.

If 0.20 is a plausible value for the parameter (it lies in the 95% CI), we do not have evidence to reject Jeffrey’s claim that the proportion is 0.20. The width or midpoint alone does not drive that conclusion.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 61%.



Source: Question 7 from Winter 2024 Final Exam

Problem 3

In our sample, we have data on 1210 medals for the sport of gymnastics. Of these, 126 were awarded to American gymnasts, 119 were awarded to Romanian gymnasts, and the remaining 965 were awarded to gymnasts from other nations.

We want to do a hypothesis test with the following hypotheses.

Null: American and Romanian gymnasts win an equal share of Olympic gymnastics medals.

Alternative: American gymnasts win more Olympic gymnastics medals than Romanian gymnasts.


Problem 3.1

Which test statistic could we use to test these hypotheses?

Answer: difference in the number of medals won by American gymnasts and the number of medals won by Romanian gymnasts

To test this pair of hypotheses, we need a test statistic that is large when the data suggests that we reject the null hypothesis, and small when we fail to reject the null. Now let’s look at each option:
- Option 1: Total variation distance across all the countries won’t tell us about the differences in medals between Americans and Romanians. In this case, it only tells how different the proportions are across all countries in comparison to the uniform distribution, the mean proportion. - Option 2: This test statistic doesn’t take into account the number of medals Romanians won. Imagine a situation where Romanians won half of all the medals and Americans won the other half, and no other country won any medals. In here, they won the same amount of medals and the test statistic would be 1/2. Now imagine if Americans win half the medals, some other country won the other half, and Romanians won no medals. In this case, the Americans won a lot more medals than Romanians but the test statistic is still 1/2. A good test statistic should point to one hypothesis when it’s large and the other hypothesis when it’s small. In this test statistic, 1/2 points to both hypotheses, making it a bad test statistic.
- Option 3: In this test statistic, when Americans win an equal amount of medals as Romanians, the test statistic would be 0, a very small number. When Americans win way more medals than Romanians, the test statistic is large, suggesting that we reject the null hypothesis in favor of the alternative. You might notice that when Romanians win way more medals than Americans, the test statistic would be negative, suggesting that we fail to reject the null hypothesis that they won equal medals. But recall that failing to reject the null doesn’t necessarily mean we think the null is true, it just means that under our null hypothesis and alternative hypothesis, the null is plausible. The important thing is that the test statistic points to the alternative hypothesis when it’s large, and points to the null hypothesis when it’s small. This test statistic does just that, so option 3 is the correct answer.
- Option 4: Since this statistic is an absolute value, large values signify a large difference in the two proportions, while small values signify a small difference in two proportions. However, it doesn’t tell which country wins more because a large value could mean that either country has a higher proportion of medals than the other. This hypothesis would only be helpful if our alternative hypothesis was that the number of medals the Americans/ Romanians win are different.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 73%.


Problem 3.2

Below are four different ways of testing these hypotheses. In each case, fill in the calculation of the observed statistic in the variable observed, such that p_val represents the p-value of the hypothesis test.

Way 1:

        many_stats = np.array([])
        for i in np.arange(10000):
            result = np.random.multinomial(245, [0.5, 0.5]) / 245
            many_stats = np.append(many_stats, result[0] - result[1])
        observed = __(a)__
        p_val = np.count_nonzero(many_stats >= observed)/len(many_stats)

Way 2:

        many_stats = np.array([])
        for i in np.arange(10000):
            result = np.random.multinomial(245, [0.5, 0.5]) / 245
            many_stats = np.append(many_stats, result[0] - result[1])
        observed = __(b)__
        p_val = np.count_nonzero(many_stats <= observed)/len(many_stats)

Way 3:

        many_stats = np.array([])
        for i in np.arange(10000):
            result = np.random.multinomial(245, [0.5, 0.5]) / 245
            many_stats = np.append(many_stats, result[0])
        observed = __(c)__ 
        p_val = np.count_nonzero(many_stats >= observed)/len(many_stats)

Way 4:

        many_stats = np.array([])
        for i in np.arange(10000):
            result = np.random.multinomial(245, [0.5, 0.5]) / 245
            many_stats = np.append(many_stats, result[0])
        observed = __(d)__ 
        p_val = np.count_nonzero(many_stats <= observed)/len(many_stats)

Answer: Way 1: 126/245 - 119/245 or 7/245

First, let’s look at what this code is doing. The line result = np.random.multinomial(245, [0.5, 0.5]) / 245 makes an array of length 2, where each of the 2 elements contains the amount of the 245 total medals corresponding to the amount of medals won by American gymnasts and Romanian gymnasts respectively. We then divide this array by 245 to turn them into proportions out of 245 (which is the sum of 126+119). This array of proportions is then assigned to result. For example, one of our 10000 repetitions could assign np.array([124/245, 121/245]) to result. The following line, many_stats = np.append(many_stats, result[0] - result[1]), appends the difference between the first proportion in result and the second proportion in result to many_stats. Using our example, this would append 124/245 - 121/245 (which equals 3/245) to many_stats. To determine how we calculate the observed statistic, we have to consider how we are calculating the p-value. In order to calculate the p-value, we need to determine how frequent it is to see a result as extreme as our observed statistic, or more extreme in the direction of the alternative hypothesis. The alternative hypothesis states that American gymnasts win more medals than Romanian gymnasts, meaning that we are looking for results in many_stats where the difference is equal to or greater than (more extreme than) 126/245 - 119/245 (which equals 7/245). That is, the final line of code in Way 1 is using np.count_nonzero to find the amount of differences in many_stats greater than 7/245. Therefore, observed must equal 7/245.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 56%.

Answer: Way 2: 119/245 - 126/245 or -7/245

The only difference between Way 2 and Way 1 is that in Way 2, the >= is switched to a <=. This causes a result as extreme or more extreme than our observed statistic to now be represented as anything less than or equal to our observed statistic. To account for this, we need to consider the first proportion in result as the number of medals won by Romanian gymnasts, and the second proportion as the number of medals won by American gymnasts. This flips the sign of all of the proportions. So instead of calculating our observed statistic as \frac{126}{245}-\frac{119}{245}, we now calculate it as \frac{119}{245}-\frac{126}{245} (which equals \frac{-7}{245}).


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 53%.

Answer: Way 3: 126/245

The difference between way 1 and way 3 is that way 3 is now taking results[0] as its test statistic instead of results[0] - results[1], which represents the number of Olympic gymnastics medals won by American gymnasts. This means that the observed statistic should be the number of medals won by America in the given sample. In that case, the observed statistics will be \frac{\text{# of American medals}}{\text{# of American medals} + \text{# of Romanian medals}} = \frac{126}{245}


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 52%.

Answer: Way 4: 119/245

Since now the sign is swapped from >= in way 3 to <= in way 4, results[0] represent the number of Romanian medals won. This is because the alternative hypothesis states that America wins more medals than Romania, demonstrating that the observed statistics is 119/245.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 50%.


Problem 3.3

The four p-values calculated in Ways 1 through 4 are:

Answer: similar, but not necessarily the same

All of these differences in test statistics and different p-values all are different, however, they are all geared towards testing through the same null and alternative hypothesis. Although they are all different methods, they are all trying to prove the same conclusion.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 71%.



Source: Question 9 from Fall 2025 Final Exam

Problem 4

As a resident of New York City, you suspect that your local news channel tends to overestimate the percent chance of snow in its daily weather forecast. To investigate this, you look at historical weather forecasts, and decide to focus specifically on days in which your local news channel had predicted a 40% chance of snow. With the benefit of hindsight, you can now see whether it actually snowed on 40% on those days.

The DataFrame snow has been queried to contain only those days that had a 40% predicted chance of snow, for New York City, stored in a new DataFrame called snow_nyc40. A few rows of snow_nyc40 are shown below, but there are more rows not pictured.

You set out to test the following hypotheses:


Problem 4.1

Fill in the blanks in the code below, which should calculate an observed test statistic, generate an empirical distribution of this test statistic under the null hypothesis, and calculate a p-value for the hypothesis test.

obs_stat = np.count_nonzero(snow_nyc40.get("snowfall"))
counts = np.array([])
for i in np.arange(10000):
    new_count = __(a)__
    counts = np.append(counts, new_count)
p_value = np.count_nonzero(counts __(b)__ obs_stat) / len(counts)

Answer (a): np.random.multinomial(snow_nyc40.shape[0], [0.4, 0.6])[0]

Answer (b): <=

If it snows on a day, the corresponding entry in "snowfall" will be greater than 0. We have a proposed distribution under the null hypothesis, which can be described as 40% days with more than zero snowfall, and 60% days with zero snowfall. To simulate counts, according to this null hypothesis, we can use np.random.multinomial(). Note that since we are comparing counts, we must use the same total as our original sample, snow_nyc40 which is given by snow_nyc40.shape[0].

Our alternative states that less than 40% of days are snow days. Note that obs_stat is computing the number of days in snow_nyc40 that experienced more than zero snowfall. So, test statistics that are smaller than or equal to the observed will be in favor of the alternative hypothesis.


Difficulty: ⭐️⭐️⭐️⭐️

The average score on this problem was 49%.


Problem 4.2

You want to test the same pair of hypotheses another way, using a different test statistic and rewriting the code in part (a). Which of the following could be the observed statistic for a new hypothesis test for the same pair of hypotheses? Select all that apply.

Answer: np.count_nonzero(snow_nyc40.get("snowfall") == 0), (snow_nyc40.get("snowfall") > 0).sum() / snow_nyc40.shape[0], and (snow_nyc40.get("snowfall") > 0).mean() - 0.40

The first choice can be used to test the following alternative: “There is no snowfall on more than 60% of the days for which the news predicts a 40% chance of snow.” This is equivalent to our original alternative hypothesis.

The second choice simply converts the original test statistic (a count) into its corresponding proportion, which isn’t going to affect our hypotheses.

The third choice also converts the test statistic into a proportion (using mean()). It additionally subtracts a constant. Since 0.40 is subtracted from all test statistics, however, the conclusion we make will not change and thus the corresponding hypotheses remain the same.

Note that snow_nyc40.get("snowfall") is not a Boolean series, therefore snow_nyc40.get("snowfall").sum() will not help us determine whether (fewer than) 40% of days are snow days.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 64%.


Problem 4.3

You also calculate a 95% CLT-based confidence interval for the proportion of days on which it actually snowed in New York City, among those for which a 40% chance of snow was predicted. Your confidence interval comes out to [0.17, 0.32]. Which of the following conclusions is correct?

Answer: Because this confidence interval does not contain the value of 0.40, it indicates that the p-value from the hypothesis test above should be below 0.05.

We can use CLT since we are working with proportions. Hence, the 95% CLT-based confidence interval for the population parameter (the true proportion) can be used to reject/fail to reject the null hypothesis. Since 0.4 (the proposed proportion under the null) does not belong in our CLT-based confidence interval for the true proportion, it lies in the (100 - 95)\% = 5\% region not contained by the confidence interval. The p-value of the hypothesis test must therefore be smaller than 0.05.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 64%.



Source: Question 20 from Winter 2021 Final Exam

Problem 5

You order 25 large pizzas from your local pizzeria. The pizzeria claims that these pizzas are 16 inches in diameter, but you’re not so sure. You measure each pizza’s diameter and collect a dataset of 25 actual pizza diameters. You want to run a hypothesis test to determine whether the pizzeria’s claim is accurate.


Problem 5.1

What would your Null Hypothesis be?

What would your Alternative Hypothesis be?

Answer:

Null Hypothesis: The mean pizza diameter at the local pizzeria is 16 inches.

Alternative Hypothesis: The mean pizza diameter at the local pizzeria is not 16 inches.

The null hypothesis is the hypothesis where there is no significant difference from some statement. In this case, the statement of interest is the pizzeria’s claims of pizzas are 16 inches in diameter.

The alternative hypothesis is a statement that contradicts the null hypothesis. In this case this statement is that the mean pizza diameter at the local pizzeria is not 16 inches. (ie. the other option to the null hypothesis)


Difficulty: ⭐️⭐️⭐️⭐️

The average score on this problem was 35%.


Problem 5.2

What test statistic would you use?

Answer: Mean Pizza Diameter, or other valid statistics such as the (absolute) difference between each pizza’s diameter and 16 (expected value)

Looking at the null and alternative hypothesis we can see we are directly interested in the mean pizza diameter, so it is most likely the best measurement for the test statistic. The main idea is that we somehow want to show the difference in distribution of the pizza diameters.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 70%.


Problem 5.3

Explain how you would do your hypothesis test and how you would draw a conclusion from your results.

Answer: Answers vary, should include the following

  • Generate confidence interval for population mean (or equivalent) by bootstrapping (or by calculating directly with the sample).

  • Correctly describe how to reject or fail to reject the null hypothesis (depending on whether interval contains 16, for example).

When conducting the hypothesis test, we first want to create a confidence interval either by using bootstrapping or constructing a 95% confidence interval to understand the true mean diameter of pizzas. The next step is to define the rejection criteria, failing to reject the null if 16 is within the 95% confidence interval (since we believe the true population mean) is within this range with 95% confidence. We will reject the null hypothesis if 16 is not within the 95% confidence interval. Note that this assumes you used true mean diameter of pizzas as your test statistic.


Difficulty: ⭐️⭐️⭐️⭐️

The average score on this problem was 38%.