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
.
Cet exercice fait partie du cours
Case Studies in Statistical Thinking
Instructions
- Use Boolean indexing to slice out the magnitudes of all earthquakes before 2010 and store the result in
mags_pre
. Similarly, generate anumpy
arraymags_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 themarker
andlinestyle
parameters. - Hit 'Submit Answer' to view the plot.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de 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()