Skip to content

Commit

Permalink
averages added to su24final 6-9
Browse files Browse the repository at this point in the history
  • Loading branch information
pallavisprabhu authored and pallavisprabhu committed Dec 3, 2024
1 parent 2eeac55 commit 1dee991
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 0 deletions.
118 changes: 118 additions & 0 deletions docs/su24-final/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ <h1 class="title"> </h1>
the direction of the difference between the categories so this is an
invalid test statistic.</li>
</ul>
<hr/>
<h5>Difficulty: ⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 79%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -907,6 +912,20 @@ <h1 class="title"> </h1>
result equal to or less than the observed, we can simply take the mean
of this array since the mean of an array of 0’s and 1’s is equivalent to
the probability.</p>
<hr/>
<h5>Difficulty: ⭐️</h5>
<p>
</p>
<p>The average score on this problem was 95%. </p>
<hr/>
<h5>Difficulty:
⭐️</h5>
<p>The average score on this problem was 100%.
</p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️⭐️</h5>
<p>The average score on this problem
was 35%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -991,6 +1010,19 @@ <h1 class="title"> </h1>
column making this answer incorrect.</li>
</ul></li>
</ul>
<hr/>
<h5>Difficulty: ⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 85%. </p>
<hr/>
<h5>Difficulty:
⭐️</h5>
<p>The average score on this problem was 90%. </p>
<hr/>
<h5>Difficulty:
⭐️⭐️</h5>
<p>The average score on this problem was 80%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1030,6 +1062,11 @@ <h1 class="title"> </h1>
can be even less than the observed value, none of them
<strong>have</strong> to be equal to the observed value. Thus, the
answer is 0.</p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 30%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1061,6 +1098,11 @@ <h1 class="title"> </h1>
context, since the p-value is 0.03, this means that there is a 3% chance
under the null hypothesis of seeing an observed difference in means
equal to or less than -22.5km.</p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 44%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1138,6 +1180,11 @@ <h1 class="title"> </h1>
winners gives magnitude but does not indicate direction making this a
valid test statistic.</li>
</ul>
<hr/>
<h5>Difficulty: ⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 80%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1208,6 +1255,32 @@ <h1 class="title"> </h1>
function, we need to return the TVD which can be calculated as follows:
<code>np.abs(simulated dist - expected dist).sum() / 2</code> in
(vi).</p>
<hr/>
<h5>Difficulty: ⭐️</h5>
<p>
</p>
<p>The average score on this problem was 90%. </p>
<hr/>
<h5>Difficulty:
⭐️</h5>
<p>The average score on this problem was 95%. </p>
<hr/>
<h5>Difficulty:
⭐️⭐️</h5>
<p>The average score on this problem was 85%.
</p>
<hr/>
<h5>Difficulty: ⭐️</h5>
<p>The average score on this problem was 95%.
</p>
<hr/>
<h5>Difficulty: ⭐️</h5>
<p>The average score on this problem was 95%.
</p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️</h5>
<p>The average score on this problem was
73%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1245,6 +1318,11 @@ <h1 class="title"> </h1>
more extreme that means we want to use <span class="math inline">&gt;=</span> in the blank to check whether the
simulated statistic is equal to or more extreme than the observed
statistic.</p>
<hr/>
<h5>Difficulty: ⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 80%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1290,6 +1368,11 @@ <h1 class="title"> </h1>
samples in lieu of a population. Bootstrapping Tour de France distances
will give samples of distances from which we can calculate the median of
Tour de France stages.</p>
<hr/>
<h5>Difficulty: ⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 75%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1321,6 +1404,11 @@ <h1 class="title"> </h1>
<p>We are comparing whether the distributions before 1960 and after 1960
are different which means we want to do permutation testing which tests
whether two samples come from the same population distribution.</p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 50%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1355,6 +1443,11 @@ <h1 class="title"> </h1>
destinations that start with letters from the second half of the
alphabet) are equal to each other which is an indicator to use a
hypothesis test.</p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 50%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1389,6 +1482,11 @@ <h1 class="title"> </h1>
from after 2000) and seeing if the first distribution is longer than the
second. Since we are comparing distributions, we want to perform a
permutation test.</p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 40%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1441,6 +1539,11 @@ <h1 class="title"> </h1>
<p><span class="math inline">- \frac{1}{3}=
\frac{5-6}{\sigma_y}</span></p>
<p><span class="math inline">\text{SD}_y = 3</span></p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 61%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1483,6 +1586,11 @@ <h1 class="title"> </h1>
slope by <span class="math inline">60</span>, giving <span class="math inline">\frac{60}{80} = \frac{3}{4}</span>. Thus we expect
Stage 14 to take <span class="math inline">\frac{3}{4}</span> hours
longer.</p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 48%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1516,6 +1624,11 @@ <h1 class="title"> </h1>
stage’s time by an additional 30 minutes. This would not change the
slope since adding time simply shifts the time data points right, but
doesn’t change the relationship between distance and time.</p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 55%.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1558,6 +1671,11 @@ <h1 class="title"> </h1>
<span class="math inline">y_{\text{su}} = r * x_{\text{su}}</span></p>
<p><span class="math inline">2 = r * 2</span></p>
<p><span class="math inline">r=1</span></p>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️⭐️</h5>
<p>
</p>
<p>The average score on this problem was 35%.</p>
</div>
</div>
</div>
Expand Down
14 changes: 14 additions & 0 deletions problems/su24-final/q06.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ A test statistic is a single number we use to test which viewpoint the data bett
- Option 4 is correct. One half of the difference between the mean distance of flat stages and the mean distance of mountain stages gives both magnitude and direction of the difference between the categories so this is a valid test statistic.
- Option 5 is incorrect. Squaring the difference between the mean distance of flat stages and the mean distance of mountain stages removes the direction of the difference between the categories so this is an invalid test statistic.

<average>79</average>


# END SOLUTION

Expand Down Expand Up @@ -77,6 +79,10 @@ def hypothesis_test(stages):

The first step in a permutation test simulation is to shuffle the labels or the values. So since this first line in the for loop is assigning a column called ‘shuffled’, we know we need to use `np.random.permutation()` on the `"Distances"` column. The next line gets the new means for each group after shuffling the values and `simulated_stat` is the simulated difference in means. Now we know we want to save this simulated statistic and we have the `simulated_stats` array, so we want to use an `np.append` in (ii) to save this statistic in the array. Finally after the simulation is complete, we calculate the p-value using the array of simulated statistics. The p-value is the probability of seeing the observed result under the null hypothesis. `simulated_stats <= observed_stat` returns an array of 0’s and 1’s depending on whether each simulated statistic is less than or equal to the observed statistic. Now, to get the probability of seeing a result equal to or less than the observed, we can simply take the mean of this array since the mean of an array of 0’s and 1’s is equivalent to the probability.

<average>95</average>
<average>100</average>
<average>35</average>

# END SOLUTION

# END SUBPROB
Expand Down Expand Up @@ -132,6 +138,10 @@ simulated_stat = (shuffled_means.get("Distance").iloc["flat"] -
- \(iii\): The code is incorrect.
- `shuffled` shuffles the distances and assigns these shuffled distances to the column `‘shuffled’`. `shuffled_means` groups by the label and calculates the means for each column. However, `simulated_stat` takes the original distance columns when calculating the difference in means rather than the shuffled distances which is located in the `‘shuffled’` column making this answer incorrect.

<average>85</average>
<average>90</average>
<average>80</average>

# END SOLUTION

# END SUBPROB
Expand All @@ -151,6 +161,8 @@ Assume that the observed statistic for this hypothesis test was equal to -22.5 k
**Solution:**
In order to reject the null hypothesis at the 0.05 significance level, the p-value needs to be below 0.05. In order to calculate the p-value, we find the proportion of simulated test statistics that are equal to or less than the observed value. Note the usage of "must be" in the problem. Since these simulated test statistics can be even less than the observed value, none of them **have** to be equal to the observed value. Thus, the answer is 0.

<average>30</average>

# END SOLUTION

# END SUBPROB # BEGIN SUBPROB
Expand All @@ -163,6 +175,8 @@ Assume that the code above generated a p-value of 0.03. In the space below, plea

The p-value is the probability of seeing the observed value or something more extreme under the null hypothesis. Knowing this, in this context, since the p-value is 0.03, this means that there is a 3% chance under the null hypothesis of seeing an observed difference in means equal to or less than -22.5km.

<average>44</average>

# END SOLUTION

# END SUBPROB
Expand Down
11 changes: 11 additions & 0 deletions problems/su24-final/q07.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Which of the following test statistics are appropriate for this hypothesis test?
- Option 3 is incorrect. The absolute difference between the number of French stage winners and the number of Italian stage winners is not a valid test statistic since the numbers in each population can be different and thus the difference in numbers is not a fair comparison.
- Option 4 is correct. The sum of the absolute differences between the expected population distribution and the observed distribution of stage winners gives magnitude but does not indicate direction making this a valid test statistic.

<average>80</average>


# END SOLUTION

Expand Down Expand Up @@ -73,6 +75,13 @@ When performing a simulation, we simulated based on the expectation. Thus, the a

We are using the total variation distance as the test statistic. The Total Variation Distance (TVD) of two categorical distributions is the sum of the absolute differences of their proportions, all divided by 2. Thus, the arguments of the `calculate_test_stat` function should be the `simulated_distribution` in (iv) and the `expected_distribution` in (v) (or swapped). In this function, we need to return the TVD which can be calculated as follows: `np.abs(simulated dist - expected dist).sum() / 2` in (vi).

<average>90</average>
<average>95</average>
<average>85</average>
<average>95</average>
<average>95</average>
<average>73</average>


# END SOLUTION

Expand All @@ -98,6 +107,8 @@ the correct p-value for this hypothesis test:

Recall the p-value is the probability of seeing a result equal to or more extreme than the observed value under the null hypothesis. Since the TVD is our test statistic where greater values indicate a result more extreme that means we want to use $>=$ in the blank to check whether the simulated statistic is equal to or more extreme than the observed statistic.

<average>80</average>

# END SOLUTION

# END SUBPROB
Expand Down
7 changes: 7 additions & 0 deletions problems/su24-final/q08.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ What is the median distance of all Tour de France stages?

Since we want the median distance of all the Tour de France stages, we are not testing anything against a hypothesis at all which rules our hypothesis testing and permutation testing. We use bootstrapping to get samples in lieu of a population. Bootstrapping Tour de France distances will give samples of distances from which we can calculate the median of Tour de France stages.

<average>75</average>

# END SOLUTION

# END SUBPROB
Expand All @@ -38,6 +40,7 @@ Is the distribution of Tour de France stage types from before 1960 the same as a

We are comparing whether the distributions before 1960 and after 1960 are different which means we want to do permutation testing which tests whether two samples come from the same population distribution.

<average>50</average>

# END SOLUTION

Expand All @@ -57,6 +60,8 @@ Are there an equal number of destinations that start with letters from the first

We are testing whether two values (the number of destinations that start with letters from the first half of the alphabet and the destinations that start with letters from the second half of the alphabet) are equal to each other which is an indicator to use a hypothesis test.

<average>50</average>

# END SOLUTION

# END SUBPROB
Expand All @@ -75,6 +80,8 @@ Are mountain stages with destinations in France from before 1970 longer than fla

We are comparing two distributions (mountain stages with destinations in France from before 1970 and flat stages with destinations in Belgium from after 2000) and seeing if the first distribution is longer than the second. Since we are comparing distributions, we want to perform a permutation test.

<average>40</average>

# END SOLUTION

# END SUBPROB
Expand Down
6 changes: 6 additions & 0 deletions problems/su24-final/q09.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ $- \frac{1}{3}= \frac{5-6}{\sigma_y}$

$\text{SD}_y = 3$

<average>61</average>

# END SOLUTION

Expand All @@ -55,6 +56,8 @@ This means that for every additional 1km, time increases by $\frac{1}{80}$.

Since Stage 14 is 60km longer than Stage 20, we simply multiply our slope by $60$, giving $\frac{60}{80} = \frac{3}{4}$. Thus we expect Stage 14 to take $\frac{3}{4}$ hours longer.

<average>48</average>

# END SOLUTION

# END SUBPROB
Expand All @@ -73,6 +76,8 @@ Suppose a mandatory rest break of 30 minutes (0.5 hours) is implemented for all

Adding a 30 minute break to all the stages simply increases each stage’s time by an additional 30 minutes. This would not change the slope since adding time simply shifts the time data points right, but doesn't change the relationship between distance and time.

<average>55</average>

# END SOLUTION

# END SUBPROB
Expand Down Expand Up @@ -104,6 +109,7 @@ $2 = r * 2$

$r=1$

<average>35</average>

# END SOLUTION

Expand Down

0 comments on commit 1dee991

Please sign in to comment.