LoslegenKostenlos loslegen

Hypothesis test: Do women swim the same way in semis and finals?

Test the hypothesis that performance in the finals and semifinals are identical using the mean of the fractional improvement as your test statistic. The test statistic under the null hypothesis is considered to be at least as extreme as what was observed if it is greater than or equal to f_mean, which is already in your namespace.

The semifinal and final times are contained in the numpy arrays semi_times and final_times.

Diese Übung ist Teil des Kurses

Case Studies in Statistical Thinking

Kurs anzeigen

Anleitung zur Übung

  • Set up an empty array to contain 1000 permutation replicates using np.empty(). Call this array perm_reps.
  • Write a for loop to generate permutation replicates.
    • Generate a permutation sample using the swap_random() function you just wrote. Store the arrays in semi_perm and final_perm.
    • Compute the value of f from the permutation sample.
    • Store the mean of the permutation sample in the perm_reps array.
  • Compute the p-value and print it to the screen.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Set up array of permutation replicates
perm_reps = ____

for i in range(1000):
    # Generate a permutation sample
    semi_perm, final_perm = ____
    
    # Compute f from the permutation sample
    f = (____ - ____) / ____
    
    # Compute and store permutation replicate
    perm_reps[i] = ____

# Compute and print p-value
print('p =', ____(____ >= ____) / 1000)
Code bearbeiten und ausführen