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 exercício faz parte do curso
Case Studies in Statistical Thinking
Instruções do exercício
- 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 itperm_reps_rho
. - Write a
for
loop to:- Scramble the split number array using
np.random.permutation()
, naming itscrambled_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
.
- Scramble the split number array using
- 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.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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)