データは私たちの仮説に合っているでしょうか?
あなたはノーヒットノーランの発生間隔を指数分布でモデル化しました。実データの ECDF を作成し、理論的な CDF と重ね合わせて表示しましょう。これにより、指数分布が観測データを記述しているかを確認できます。
ECDF を計算するために[前のコースで作成した関数](https://campus.datacamp.com/courses/statistical-thinking-in-python-part-1/graphical-exploratory-data-analysis?ex=12)や、[それをプロットするコード](https://campus.datacamp.com/courses/statistical-thinking-in-python-part-1/graphical-exploratory-data-analysis?ex=13)を思い出しておくと役に立ちます。
この演習はコースの一部です
Pythonで学ぶ統計思考(パート2)
演習の手順
- ノーヒットノーランの間隔の実データ(
nohitter_times)から ECDF を計算します。前編コースで作成したecdf()関数を使ってください。 - 前の演習で取得した理論サンプル(
inter_nohitter_time)から CDF を作成します。 plt.plot()を使ってx_theorとy_theorを線でプロットします。続いて、実データの ECDF であるxとyを点で重ねます。そのために、plt.plot()の引数にxとyに加えて、キーワード引数marker = '.'とlinestyle = 'none'を指定します。- プロットの余白を 2% に設定します。
- プロットを表示します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Create an ECDF from real data: x, y
x, y = ____
# Create a CDF from theoretical samples: x_theor, y_theor
x_theor, y_theor = ____
# Overlay the plots
plt.plot(____, ____)
plt.plot(____, ____, marker=____, linestyle=____)
# Margins and axis labels
plt.margins(____)
plt.xlabel('Games between no-hitters')
plt.ylabel('CDF')
# Show the plot
plt.show()