1. Learn
  2. /
  3. Courses
  4. /
  5. Case Studies in Statistical Thinking

Connected

Exercise

Hypothesis test: are they slowing down?

Now we will test the null hypothesis that the swimmer's split time is not at all correlated with the distance they are at in the swim. We will use the Pearson correlation coefficient (computed using dcst.pearson_r()) as the test statistic.

Instructions

100 XP
  • Compute the observed Pearson correlation, storing it as rho.
  • Using np.empty(), initialize the array of 10,000 permutation replicates of the Pearson correlation, naming it perm_reps_rho.
  • Write a for loop to:
    • Scramble the split number array using np.random.permutation(), naming it scrambled_split_number.
    • Compute the Pearson correlation coefficient between the scrambled split number array and the mean split times and store it in perm_reps_rho.
  • Compute the p-value and display it on the screen. Take "at least as extreme as" to mean that the Pearson correlation is at least as big as was observed.