Exercise

Hypothesis test: can this be by chance?

The EDA and linear regression analysis is pretty conclusive. Nonetheless, you will top off the analysis of the zigzag effect by testing the hypothesis that lane assignment has nothing to do with the mean fractional difference between even and odd lanes using a permutation test. You will use the Pearson correlation coefficient, which you can compute with dcst.pearson_r() as the test statistic. The variables lanes and f_13 are already in your namespace.

Instructions

100 XP
  • Compute the observed Pearson correlation coefficient, storing it as rho.
  • Initialize an array to store the 10,000 permutation replicates of rho using np.empty(). Name the array perm_reps_rho.
  • Write a for loop to draw the permutation replicates.
    • Scramble the lanes array using np.random.permutation().
    • Compute the Pearson correlation coefficient between the scrambled lanes array and f_13. Store the result in perm_reps_rho.
  • Compute and print the p-value. Take "at least as extreme as" to be that the Pearson correlation coefficient is greater than or equal to what was observed.