2標本のための proportions_ztest()
p値を計算するのは大変でしたね。計算の仕組みを理解するのは有益ですが、実務の分析で毎回手計算するのは現実的ではありません。日常的には statsmodels パッケージを使うのが便利です。
仮説を思い出しましょう。
\(H_{0}\): \(late_{\text{expensive}} - late_{\text{reasonable}} = 0\)
\(H_{A}\): \(late_{\text{expensive}} - late_{\text{reasonable}} > 0\)
late_shipments が利用可能で、freight_cost_group 列を含みます。numpy と pandas は標準のエイリアスで読み込まれており、proportions_ztest は statsmodels.stats.proportion から読み込まれています。
この演習はコースの一部です
Pythonで学ぶ仮説検定
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Count the late column values for each freight_cost_group
late_by_freight_cost_group = ____
# Print the counts
print(late_by_freight_cost_group)