Bootstrap 假設檢定

Statistical Thinking in Python(第 2 部分)

Justin Bois

Lecturer at the California Institute of Technology

假設檢定流程

  • 清楚陳述虛無假設
  • 定義檢定統計量
  • 在虛無假設為真下,產生多組模擬資料
  • 對每組模擬資料計算檢定統計量
  • p 值為檢定統計量「至少與真實資料一樣極端」的模擬資料比例
Statistical Thinking in Python(第 2 部分)

Michelson 與 Newcomb:測量光速的先驅

第 3 章圖片 ch3-3.008.png

1 Michelson 圖片:公有領域,Smithsonian 2 Newcomb 圖片:美國國會圖書館
Statistical Thinking in Python(第 2 部分)

Michelson 與 Newcomb:測量光速的先驅

第 3 章圖片 ch3-3.010.png

1 Michelson 圖片:公有領域,Smithsonian 2 Newcomb 圖片:美國國會圖書館
Statistical Thinking in Python(第 2 部分)

我們擁有的資料

第 3 章圖片 ch3-3.011.png

1 資料:Michelson,1880 年
Statistical Thinking in Python(第 2 部分)

虛無假設

  • Michelson 實驗中的真實光速平均值其實等於 Newcomb 報告的數值。
Statistical Thinking in Python(第 2 部分)

平移 Michelson 的資料

newcomb_value = 299860  # km/s
michelson_shifted = michelson_speed_of_light \\
           - np.mean(michelson_speed_of_light) + newcomb_value

第 3 章圖片 ch3-3.019.png

Statistical Thinking in Python(第 2 部分)

計算檢定統計量

def diff_from_newcomb(data, newcomb_value=299860):
    return np.mean(data) - newcomb_value
diff_obs = diff_from_newcomb(michelson_speed_of_light)

diff_obs
-7.5999999999767169
Statistical Thinking in Python(第 2 部分)

計算 p 值

bs_replicates = draw_bs_reps(michelson_shifted,
                             diff_from_newcomb, 10000)

p_value = np.sum(bs_replicates <= diff_observed) / 10000
p_value
0.16039999999999999
Statistical Thinking in Python(第 2 部分)

 

單一樣本檢定

- 將一組資料與單一數值比較

 

兩樣本檢定

- 比較兩組資料
Statistical Thinking in Python(第 2 部分)

一起來練習吧!

Statistical Thinking in Python(第 2 部分)

Preparing Video For Download...