Bootstrapové testy hypotéz

Statistical Thinking in Python (Part 2)

Justin Bois

Lecturer at the California Institute of Technology

Postup testování hypotéz

  • Jasně formulujte nulovou hypotézu
  • Definujte testovou statistiku
  • Vygenerujte mnoho simulovaných datových sad za předpokladu platnosti nulové hypotézy
  • Vypočítejte testovou statistiku pro každou simulovanou datovou sadu
  • P-hodnota je podíl simulovaných datových sad, pro které je testová statistika alespoň tak extrémní jako pro reálná data
Statistical Thinking in Python (Part 2)

Michelson a Newcomb: průkopníci měření rychlosti světla

ch3-3.008.png

1 Fotografie Michelsona: public domain, Smithsonian 2 Fotografie Newcomba: Knihovna Kongresu USA
Statistical Thinking in Python (Part 2)

Michelson a Newcomb: průkopníci měření rychlosti světla

ch3-3.010.png

1 Fotografie Michelsona: public domain, Smithsonian 2 Fotografie Newcomba: Knihovna Kongresu USA
Statistical Thinking in Python (Part 2)

Dostupná data

ch3-3.011.png

1 Data: Michelson, 1880
Statistical Thinking in Python (Part 2)

Nulová hypotéza

  • Skutečná střední rychlost světla v Michelsonových experimentech byla hodnota, kterou naměřil Newcomb
Statistical Thinking in Python (Part 2)

Posun Michelsonových dat

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

Posun Michelsonových dat

Statistical Thinking in Python (Part 2)

Výpočet testové statistiky

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 (Part 2)

Výpočet p-hodnoty

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 (Part 2)

 

Jednovýběrový test

- Porovnání jedné datové sady s jednou hodnotou

 

Dvouvýběrový test

- Porovnání dvou datových sad
Statistical Thinking in Python (Part 2)

Pojďme si procvičit!

Statistical Thinking in Python (Part 2)

Preparing Video For Download...