Parkfield 的地震間隔時間估計
在這個練習中,你會先計算指數分佈與常態分佈模型的最佳參數估計,用來描述地震之間的間隔時間。接著,你會將這些模型的理論 CDF 與 Parkfield 真實地震間隔時間的正式 ECDF 一起繪圖比較。
本練習屬於課程
統計思維個案研究
練習說明
- 計算地震間隔時間的平均值,存成
mean_time_gap。大地震之間的間隔時間(單位為年)已存於time_gap。 - 計算地震間隔時間的標準差,存成
std_time_gap。 - 使用
np.random.exponential(),以適當的平均值,從指數分佈抽取 10,000 個樣本。將結果存為time_gap_exp。 - 使用
np.random.normal(),以適當的平均值與標準差,從常態分佈抽取 10,000 個樣本。將結果存為time_gap_norm。 - 各以一條線繪出理論 CDF,使用本章先前介紹的
*dcst.ecdf()方法。 - 使用關鍵字引數
formal=True、min_x=-10、max_x=50來繪製 ECDF。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Compute the mean time gap: mean_time_gap
mean_time_gap = ____
# Standard deviation of the time gap: std_time_gap
std_time_gap = ____
# Generate theoretical Exponential distribution of timings: time_gap_exp
time_gap_exp = ____
# Generate theoretical Normal distribution of timings: time_gap_norm
time_gap_norm = ____
# Plot theoretical CDFs
_ = plt.plot(*____)
_ = plt.plot(*____)
# Plot Parkfield ECDF
_ = plt.plot(*____(____, ____=____, ____=____, ____=____))
# Add legend
_ = plt.legend(('Exp.', 'Norm.'), loc='upper left')
# Label axes, set limits and show plot
_ = plt.xlabel('time gap (years)')
_ = plt.ylabel('ECDF')
_ = plt.xlim(-10, 50)
plt.show()