P-Değerini Görselleştirme
Bu egzersizde, tahmin ettiğimiz etkinin (veya "hızın") örneklemdeki rastgele değişim sonucu ortaya çıkma olasılığı olan p-değerini görselleştireceksin. Amacın, karıştırılmış test istatistiği dağılımındaki noktaların, karıştırılmamış örneklerden hesaplanan test istatistiğinin ortalamasının ("etki büyüklüğü") sağında kalan kısmını görselleştirmek.
Başlaman için, group_duration_short ve group_duration_long ile compute_test_statistic(), shuffle_and_split() ve plot_test_statistic_effect() fonksiyonlarını önceden yükledik.
Bu egzersiz, kursun bir parçasıdır
Python ile Doğrusal Modellemenin Temelleri
Egzersiz talimatları
compute_test_statistic()ilegroup_duration_shortvegroup_duration_longkullanaraktest_statistic_unshuffleddeğerini elde et; ardındannp.mean()ile etki büyüklüğünü (effect size) hesapla.shuffle_and_split()kullanarakshuffle_half1veshuffle_half2oluştur vecompute_test_statistic()iletest_statistic_shuffleddeğerini hesapla.test_statistic_shuffleddeğerlerinineffect_size’e büyük ya da eşit olduğu bir boolean maskeconditionoluştur; ardından bu maskeyi kullanarakp_valuehesapla.p_value’u yazdır ve her iki test istatistiğiniplot_test_statistic_effect()ile görselleştir.
Uygulamalı etkileşimli egzersiz
Bu egzersizi bu örnek kodu tamamlayarak deneyin.
# Compute the test stat distribution and effect size for two population groups
test_statistic_unshuffled = compute_test_statistic(____, ____)
effect_size = np.mean(____)
# Randomize the two populations, and recompute the test stat distribution
shuffled_half1, ____ = shuffle_and_split(group_duration_short, ____)
test_statistic_shuffled = compute_test_statistic(shuffled_half1, ____)
# Compute the p-value as the proportion of shuffled test stat values >= the effect size
condition = ____ >= ____
p_value = len(test_statistic_shuffled[____]) / len(test_statistic_shuffled)
# Print p-value and overplot the shuffled and unshuffled test statistic distributions
print("The p-value is = {}".format(____))
fig = plot_test_stats_and_pvalue(test_statistic_unshuffled, test_statistic_shuffled)