Fall 2025 Quiz 4

Appearance

← return to practice.dsc10.com


This quiz was administered in-person. Students were allowed 1 double-sided cheatsheet. Students had 20 minutes to work on the quiz.

This quiz covered Lectures 16-18 of the Fall 2025 offering of DSC 10.

⚠️ PDF version available here .


That's the end of the quiz.

Ryan works at Geisel Library. He counts the number of students on Geisel’s second floor at 10 AM for some days in summer and fall, storing them in DataFrames summer (top) and fall (bottom). The first few rows are shown, along with the mean and standard deviation of the "students" column.

summer

Mean = 40
SD = 10

fall

Mean = 400
SD = 10

Problem 1

Lecture 16

At least what proportion of summer.get("students") is in the range [30,40]?

Answer: \geq 0.00

Chebyshev’s inequality says that for any distribution, at least 1 - \frac{1}{z^2} of the data is within z standard deviations of the mean. The mean is 40 and the standard deviation is 10, so the range [30, 40] is the left half of the range within 1 standard deviation of the mean, [30, 50].

With z = 1, Chebyshev’s inequality guarantees at least 1 - \frac{1}{1^2} = 0 of the data in [30, 50], which is no guarantee at all. It also says nothing about how the data is split between the two sides of the mean. So the only proportion we can guarantee in [30, 40] is 0.

The other choices don’t work. 0.75 is the guarantee for the range within 2 standard deviations, [20, 60]. 0.68 is the rule of thumb for normally distributed data, and we don’t know that this data is normal.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 66%.


Problem 2

Lecture 16

Ryan runs the code below to make a single array with the contents of the "students" columns from both summer and fall.

    combined = np.append(summer.get("students"), fall.get("students"))


Problem 2.1

Select all of the true statements below:

Answer: Options 2 and 4.

The mean of combined is a weighted average of the summer mean, 40, and the fall mean, 400, so it must be between 40 and 400. Option 2 is true.

Option 1 is false. The mean would only be 220 (halfway between 40 and 400) if summer and fall had the same number of rows, and we don’t know that.

The standard deviation measures how spread out the data is around the mean. The combined data has two groups of values, one around 40 and one around 400, and the combined mean is somewhere in between. Most values are far from the combined mean, much farther than the typical distance of 10 within each group. So the standard deviation of combined is greater than 10. Option 4 is true and Option 3 is false.


Difficulty: ⭐️⭐️

The average score on this problem was 83%.


Problem 2.2

Since he was in a rush, Ryan asked ChatGPT to write code that standardizes combined. To his surprise, 90\% of the standardized data is less than 0. Which of the following best explains this situation?

Answer: Option 4.

A value is negative after standardizing exactly when it is below the mean, since standardizing subtracts the mean. So 90\% of the standardized data being less than 0 means 90\% of the original data is below the mean. This happens when the data is skewed, because a few very large values can pull the mean up above most of the data. Here, if summer has many more rows than fall, the large fall values pull the mean up, so most values are below it.

The first option is wrong because standardizing the data correctly doesn’t prevent this. The second is wrong because standardized values can be negative even when the original values are not. The third is wrong because the mean is the average of the data, so some values must be above it, and it’s impossible for 100\% of the data to be below the mean.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 66%.



Problem 3

Lecture 16

For this question only, suppose we know that summer.get("students") is normally distributed. You randomly select one number from summer.get("students"). Using the function scipy.stats.norm.cdf, write one line of code that evaluates to the probability that the number you selected is in the range [30,45].

Answer: scipy.stats.norm.cdf(0.5) - scipy.stats.norm.cdf(-1)

scipy.stats.norm.cdf(z) gives the area under the standard normal curve to the left of z, so it works with standardized values. To convert, subtract the mean and divide by the standard deviation, which are 40 and 10 for summer.

The left endpoint 30 is \frac{30 - 40}{10} = -1 standard deviations from the mean, and the right endpoint 45 is \frac{45 - 40}{10} = 0.5 standard deviations from the mean. The area between them is the area to the left of 0.5 minus the area to the left of -1, which gives the answer above.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 55%.


Problem 4

Lecture 17

Ryan writes the following code to obtain a 95% bootstrapped confidence interval for the mean number of students in Geisel’s second floor at 10AM in the fall only:

stats = np.array([])
for i in range(3333):
    stat = fall.sample(fall.shape[0], 
                       replace=True).get("students").mean()
    stats = np.append(stats, stat)
lower = np.percentile(stats, 2.5)
upper = np.percentile(stats, 97.5)


Problem 4.1

Write one line of code that evaluates to the upper endpoint of the 95\% CLT-based confidence interval for this same parameter. Recall that some potentially relevant values are provided with the DataFrames on the previous page.

Answer: 400 + 2 * 10 / fall.shape[0] ** 0.5

The Central Limit Theorem says the distribution of the sample mean is roughly normal, centered at the mean of the sample with a standard deviation of \frac{\text{sample SD}}{\sqrt{\text{sample size}}}. A 95\% confidence interval goes from 2 of those standard deviations below the mean to 2 above it.

For fall, the mean is 400, the standard deviation is 10, and the sample size is fall.shape[0]. The upper endpoint is the mean plus 2 standard deviations of the sample mean, which is the answer above.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 65%.


Problem 4.2

True or False: The 95\% confidence interval generated by the bootstrapping code above cannot be narrower than a 95% confidence interval generated by the Central Limit Theorem.

Answer: False

The bootstrap interval is built from random resamples, so it changes slightly each time we run the code. The CLT interval is computed from a formula. Both methods approximate the same interval, but neither is guaranteed to be wider. By chance, the bootstrap interval can come out narrower than the CLT interval.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 69%.


Problem 4.3

True or False: The Central Limit Theorem tells us that the data in fall.get("students") is roughly normally distributed.

Answer: False

The Central Limit Theorem is about the distribution of the sample mean (or sum) across many random samples, which is roughly normal when the sample is large. It says nothing about the shape of the original data, which can have any distribution.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 62%.


Problem 4.4

True or False: To obtain a 95% bootstrapped confidence interval for the median, we can simply change .mean() to .median() in the original code above.

Answer: True

Bootstrapping works for any statistic we can compute from a sample. Each resample is drawn the same way, and we just compute the median of each resample instead of the mean. The 2.5th and 97.5th percentiles of those medians then give the middle 95\% of the bootstrapped medians.


Difficulty: ⭐️⭐️

The average score on this problem was 80%.


Problem 4.5

True or False: We can use the CLT to create a valid 95\% confidence interval for the median.

Answer: False

The Central Limit Theorem only applies to sample means and sums, and proportions are a kind of mean. The median is not a mean, so the CLT doesn’t tell us how its distribution looks. To get a confidence interval for the median, we use bootstrapping.


Difficulty: ⭐️⭐️

The average score on this problem was 86%.



Problem 5

Lecture 18

Suppose Ryan is interested in collecting data and using it to form a 95\% confidence interval for the proportion of UCSD students that have ever been to Geisel library.

Write an expression that evaluates to the minimum sample size required for the confidence interval to have a width of at most 0.2.

Answer: (4 * 0.5 / 0.2) ** 2

The proportion of students who have been to Geisel is the mean of data made of 0s and 1s, so we can use the CLT. A 95\% confidence interval goes from 2 standard deviations of the sample mean below the mean to 2 above, so its width is 4 \times \frac{\text{SD}}{\sqrt{n}}.

We don’t know the SD before collecting data, so we use its largest possible value. For data made of 0s and 1s, the SD is at most 0.5. Using that guarantees the interval is no wider than 0.2 whatever the true proportion is.

We need 4 \times \frac{0.5}{\sqrt{n}} \leq 0.2. Solving for n gives \sqrt{n} \geq \frac{4 \times 0.5}{0.2}, so n \geq \left(\frac{4 \times 0.5}{0.2}\right)^2, which equals 100.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 67%.


👋 Feedback: Find an error? Still confused? Have a suggestion? Let us know here.