Get startedGet started for free

Hypothesis test: are the b-values different?

Perform the hypothesis test sketched out on the previous exercise. The variables mags_pre and mags_post are already loaded into your namespace, as is mt = 3.

This exercise is part of the course

Case Studies in Statistical Thinking

View Course

Exercise instructions

  • Slice out the magnitudes of earthquakes before 2010 that have a magnitude above (or equal) the completeness threshold and overwrite mags_pre with the result. Do the same for mags_post.
  • Compute the observed difference in mean magnitudes, subtracting the magnitudes of pre-2010 earthquakes from those of post-2010 earthquakes.
  • Generate 10,000 permutation replicates using dcst.draw_perm_reps(). Use dcst.diff_of_means as the argument for func.
  • Compute and print the p-value taking "at least as extreme as" to mean that the test statistic is smaller than what was observed.

Hands-on interactive exercise

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

# Only magnitudes above completeness threshold
mags_pre = ____[____ >= ____]
mags_post = ____[____ >= ____]

# Observed difference in mean magnitudes: diff_obs
diff_obs = ____ - ____

# Generate permutation replicates: perm_reps
perm_reps = ____

# Compute and print p-value
p_val = ____(____ < ____) / 10000
print('p =', p_val)
Edit and Run Code