將百分位數與 ECDF 比較
為了觀察百分位數與 ECDF 的關係,你將把上一個練習中計算出的 Iris versicolor 花瓣長度百分位數,疊加到你在第 1 章產生的 ECDF 圖上。前一題的百分位數變數已在工作環境中提供,分別為 ptiles_vers 與 percentiles。
注意:為了讓 ECDF 圖的 y 軸維持在 0 到 1,你需要對 percentiles 進行重新縮放——在此情境下,將它除以 100。
本練習屬於課程
Statistical Thinking in Python (Part 1)
練習說明
- 在 ECDF 上以紅色菱形標出百分位數。將 x、y 座標(
ptiles_vers與percentiles/100)作為位置引數傳入,並指定關鍵字引數marker='D'、color='red'、linestyle='none'。y 軸的引數percentiles/100已替你填好。 - 顯示該圖。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Plot the ECDF
_ = plt.plot(x_vers, y_vers, '.')
_ = plt.xlabel('petal length (cm)')
_ = plt.ylabel('ECDF')
# Overlay percentiles as red diamonds.
_ = plt.plot(____, percentiles/100, ____='D', ____='red',
____=____)
# Show the plot