Get startedGet started for free

Permutation test: wild type versus heterozygote

Test the hypothesis that the heterozygote and wild type bout lengths are identically distributed using a permutation test.

This exercise is part of the course

Case Studies in Statistical Thinking

View Course

Exercise instructions

  • Compute the difference of means (heterozygote minus wild type bout lengths) of the actual datasets, storing the result in the variable diff_means_exp. The numpy arrays bout_lengths_wt and bout_lengths_het are already in your namespace.
  • Draw 10,000 permutation replicates of the difference of means using dcst.draw_perm_reps(). You can use the dcst.diff_of_means() function as well, storing your result in perm_reps.
  • Compute the p-value, defining "at least as extreme as" to be that the difference of means under the null hypothesis is greater than or equal to that which was observed experimentally.
  • Print the p-value to the screen.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Compute the difference of means: diff_means_exp
diff_means_exp = ____ - ____

# Draw permutation replicates: perm_reps
perm_reps = ____(____, ____, 
                               ____, size=____)

# Compute the p-value: p-val
p_val = ____(____ >= ____) / len(____)

# Print the result
print('p =', p_val)
Edit and Run Code