兩個樣本的 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 已以預設別名載入,且已從 statsmodels.stats.proportion 載入 proportions_ztest。
本練習屬於課程
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)