開始使用免費開始

視覺化適合度檢定

卡方適合度檢定(chi-square goodness of fit test)會將類別變數各水準的比例與假設值進行比較。在執行檢定之前,先把樣本中的分布與假設的分布做視覺化比較,通常很有幫助。

回想 late_shipments 資料集中的供應商貿易條件(incoterms)。你假設在所有出貨的母體中,以下四個值的出現頻率為:

  • CIP:0.05
  • DDP:0.1
  • EXW:0.75
  • FCA:0.1

這些頻率已儲存在 hypothesized DataFrame 中。

incoterm_counts DataFrame 儲存了 vendor_inco_term 欄位的 .value_counts() 結果。

late_shipments 可直接使用;pandasmatplotlib.pyplot 已以標準別名載入。

本練習屬於課程

Python 中的假設檢定

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Find the number of rows in late_shipments
n_total = ____

# Print n_total
print(n_total)
編輯並執行程式碼