BaşlayınÜcretsiz başlayın

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

Kursa Göz Atın

Egzersiz talimatları

  • compute_test_statistic() ile group_duration_short ve group_duration_long kullanarak test_statistic_unshuffled değerini elde et; ardından np.mean() ile etki büyüklüğünü (effect size) hesapla.
  • shuffle_and_split() kullanarak shuffle_half1 ve shuffle_half2 oluştur ve compute_test_statistic() ile test_statistic_shuffled değerini hesapla.
  • test_statistic_shuffled değerlerinin effect_size’e büyük ya da eşit olduğu bir boolean maske condition oluştur; ardından bu maskeyi kullanarak p_value hesapla.
  • p_value’u yazdır ve her iki test istatistiğini plot_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)
Kodu Düzenle ve Çalıştır