Get startedGet started for free

EDA: Comparing magnitudes before and after 2010

Make an ECDF of earthquake magnitudes from 1980 through 2009. On the same plot, show an ECDF of magnitudes of earthquakes from 2010 through mid-2017. The time of the earthquakes, as decimal years, are stored in the NumPy array time and the magnitudes in the NumPy array mags.

This exercise is part of the course

Case Studies in Statistical Thinking

View Course

Exercise instructions

  • Use Boolean indexing to slice out the magnitudes of all earthquakes before 2010 and store the result in mags_pre. Similarly, generate a numpy array mags_post that has all magnitudes of earthquakes in and after 2010.
  • Use plt.plot() with a *dcst.ecdf(____) argument to make ECDFs for pre- and post- 2010 earthquake magnitudes. Remember to specify arguments for the marker and linestyle parameters.
  • Hit 'Submit Answer' to view the plot.

Hands-on interactive exercise

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

# Get magnitudes before and after 2010
mags_pre = ____[____ < ____]
mags_post = ____[____ >= ____]

# Generate ECDFs


# Label axes and show plot
_ = plt.xlabel('magnitude')
_ = plt.ylabel('ECDF')
plt.legend(('1980 though 2009', '2010 through mid-2017'), loc='upper left')
plt.show()
Edit and Run Code