ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Case Studies in Statistical Thinking

Ver curso

Instrucciones del ejercicio

  • 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.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Observed correlation
rho = ____

# Initialize permutation reps
perm_reps_rho = ____

# Make permutation reps
for i in range(10000):
    # Scramble the split number array
    scrambled_split_number = ____
    
    # Compute the Pearson correlation coefficient
    ____[i] = ____
    
# Compute and print p-value
p_val = ____(____ >= ____) / ____
print('p =', p_val)
Editar y ejecutar código