← return to practice.dsc10.com
This quiz was administered in-person. Students were allowed a
double-sided sheet of handwritten notes. Students had 20
minutes to work on the quiz.
This quiz covered Lectures
22-25 of the Winter 2025 offering
of DSC 10.
⚠️ PDF version available here .
UCSD is testing whether a new version of the TritonLink website will improve student engagement. Each student who visits the Tritonlink website receives either the old version or the new version at random, and the number of minutes spent on the site is recorded.
The results of the experiment are stored in the DataFrame
tritonlink, whose first few rows are shown at right.

Let’s do a permutation test with the following hypotheses:
Null Hypothesis: The amount of time students spend on the TritonLink website is the same for both versions of the website.
Alternative Hypothesis: Students spend more time on the new version of the site.
For our test statistic, we’ll use the mean time spent on the new version of the site minus the mean time spent on the old version of the site. The function below should compute one simulated difference of this statistic under the null hypothesis.
def one_stat():
shuffled = np.random.permutation(__(a)__)
shuffled_df = tritonlink.assign(shuffled = shuffled)
grouped = shuffled_df.get(["shuffled", "minutes"]).groupby(__(b)__).mean().get("minutes")
return __(c)__
(i) Which of the following statements about blank (a) is
correct?
We can shuffle either "minutes" or
"version" because it doesn’t matter which column we shuffle
in a permutation test.
We must shuffle "minutes" because only numerical data
can be shuffled in a permutation test.
We must shuffle "version" because only group labels can
be shuffled in a permutation test.
We must shuffle "minutes" because of the structure of
the provided code.
We must shuffle "version" because of the structure of
the provided code.
(ii) Fill in blanks (b) and (c).
(i): Option E
Follow the code line by line:
shuffled = np.random.permutation(__(a)__)
shuffled_df = tritonlink.assign(shuffled = shuffled)
grouped = (shuffled_df.get(["shuffled", "minutes"]).groupby(__(b)__).mean().get("minutes"))
"shuffled"."shuffled" and
"minutes", and later call .get("minutes")
after grouping and taking the mean."minutes" is the column being
averaged, "shuffled" must be the column we
group by. You group by labels
("old"/"new"), not by numbers. So
"shuffled" has to hold the shuffled "version"
labels.If we shuffled "minutes" instead, the DataFrame would
contain the original, unshuffled "minutes"
column and a shuffled-minutes column, with no version labels left at
all. Grouping and averaging wouldn’t make sense.
(ii):
(b): "shuffled"
We group by the shuffled labels, not the original
"version" column. Grouping by "version" would
just recompute the observed statistic every time, with no randomness.
Also, "version" isn’t even in the DataFrame at that point,
because .get(["shuffled", "minutes"]) dropped it, so it
would cause an error.
(c):
grouped.loc["new"] - grouped.loc["old"]
After .groupby("shuffled").mean().get("minutes"),
grouped is a Series:
the index is the group labels, "new" and
"old" (sorted alphabetically),
the values are the mean minutes for each shuffled group.
The average score on this problem was 61%.
Suppose we complete our permutation test and calculate a p-value. Which of the following statements are true? Select all that apply.
If the p-value is 0.18, this means that if the alternative hypothesis is true, the probability of seeing a difference as or more extreme as the observed difference is about 18\%.
If the p-value is 0.03, this means that if the null hypothesis is true, the probability of seeing a difference as or more extreme as the observed difference is about 3\%.
If the p-value is 0, this means that we implemented our permutation test incorrectly.
If the p-value is 0.5, this means that exactly half of the simulated test statistics were less extreme than our observed difference.
None of the above.
Answer: Options 2 and 4
Option 1: False. The p-value is always calculated assuming the null is true. That’s how the simulation works: shuffling labels only makes sense if the labels don’t matter, which is the null. The p-value says nothing about probabilities under the alternative.
Option 2: True. This is the definition, word for word. (It’s “about” 3% because a simulation only estimates the probability.)
Option 3: False. A p-value of 0 just means none of the simulated statistics were as extreme as the observed one. That happens when the observed difference is very unusual under the null, for example a big difference with lots of data. It’s strong evidence against the null, not a sign of a bug. (The true probability isn’t literally 0. It’s just too small to show up in, say, 10,000 simulations.)
Option 4: True, by complement.
p = 0.5 means exactly 50% of the simulated statistics were as or more extreme (≥ observed).
Every simulated statistic is either “as or more extreme” or “less extreme,” never both. So the other 50% were less extreme.
The average score on this problem was 75%.
For the DataFrame df shown in full below, both the
"x" and "y" columns have a mean of 0 and a
standard deviation of 1. Calculate the correlation between
"x" and "y".

Answer: 0.6
The correlation coefficient is the mean of the products of x and y, both in standard units:
r = \text{mean}\big( x_{\text{su}} \cdot y_{\text{su}} \big), \qquad x_{\text{su}} = \frac{x - \text{mean}(x)}{\text{SD}(x)}
The quiz says both columns have mean 0 and SD 1, so the data is already in standard units. Converting gives back the same numbers, since (x − 0)/1 = x. So we just multiply each row’s x and y and take the average:
| row | x | y | x · y |
|---|---|---|---|
| 0 | −2 | −1 | 2 |
| 1 | −1 | −1 | 1 |
| 2 | 0 | −1 | 0 |
| 3 | 0 | −1 | 0 |
| 4 | 0 | −1 | 0 |
| 5 | 0 | 1 | 0 |
| 6 | 0 | 1 | 0 |
| 7 | 0 | 1 | 0 |
| 8 | 1 | 1 | 1 |
| 9 | 2 | 1 | 2 |
| Sum | 6 |
r = \frac{6}{10} = 0.6
The average score on this problem was 48%.
UCSD uses a system called EASy for students to submit requests for enrollment if they need an exception to the enrollment requirements. Naturally, bigger classes generally receive more EASy requests.
Suppose the average number of seats per class (x) is 75, with a standard deviation of 25, and the average number of EASy requests per class (y) is 10, with a standard deviation of 4.
For this subpart only, suppose the correlation between x and y is 0.5. Use the regression line to predict the number of EASy requests for a class with 100 seats. Give your answer as an integer.
Answer: 12
Step 1. Convert x to standard units: x_{\text{su}} = \frac{100 - 75}{25} = 1 A 100-seat class is 1 SD above the average class size.
Step 2. Multiply by r: \text{predicted } y_{\text{su}} = 0.5 \times 1 = 0.5 The prediction is only 0.5 SDs above average for y. This is regression to the mean: when |r| < 1, the prediction is fewer SDs from the mean than x is.
Step 3. Convert back to original units: \text{predicted } y = 10 + 0.5 \times 4 = 12
The average score on this problem was 67%.
A Japanese class has 150 seats and receives 16 EASy requests. Say we use linear regression to predict the number of EASy requests from the number of seats, and find that the squared residual for this Japanese class is 4. What is the smallest possible correlation between x and y in this case? Give your answer as a simplified fraction.
Answer: 1/3
Step 1. Find the residual. Residual = actual − predicted. The squared residual is 4, so: \text{residual} = +2 \quad \text{or} \quad \text{residual} = -2 Squaring loses the sign, so we have to check both cases.
Step 2. Turn each residual into a prediction. The actual value is 16 requests: - residual = +2 → predicted = 16 − 2 = 14 - residual = −2 → predicted = 16 + 2 = 18
Step 3. Write the prediction in terms of r. The Japanese class has 150 seats: x_{\text{su}} = \frac{150 - 75}{25} = 3 \text{predicted } y = 10 + (r \cdot 3)\cdot 4 = 10 + 12r
Step 4. Solve for r in each case. - 10 + 12r = 14 → 12r = 4 → r = 1/3 - 10 + 12r = 18 → 12r = 8 → r = 2/3
Both values are between −1 and 1, so both are possible correlations. The question asks for the smallest, so the answer is r = 1/3.
The average score on this problem was 36%.