Test İstatistiklerini Görselleştirme
Bu egzersizde, sıfır hipotezine iki farklı yolla elde edilen bir test istatistiğinin dağılımını karşılaştırarak yaklaşacaksın.
Önce, erken ve geç zamanlara göre gruplanmış iki "anakütleyi" inceleyip test istatistiği dağılımını hesaplayacaksın. Sonra, iki anakütleyi karıştırarak zaman sırasını bozacak, her birine erken ve geç zamanlardan bir karışım verecek ve test istatistiği dağılımını yeniden hesaplayacaksın.
Başlaman için, iki zaman süresi grubunu (group_duration_short ve group_duration_long) ve iki fonksiyonu (shuffle_and_split() ve plot_test_statistic()) önceden yükledik.
Bu egzersiz, kursun bir parçasıdır
Python ile Doğrusal Modellemenin Temelleri
Egzersiz talimatları
np.random.choice()kullanarakgroup_duration_shortvegroup_duration_longüzerinde yeniden örnekleme yap ve yeniden örneklemelerin farkını alaraktest_statistic_unshuffleddeğerini hesapla.- Orijinal
group_duration_shortvegroup_duration_longüzerinde (bu sırayla belirtilmiştir)shuffle_and_split()kullanarak iki yeni karışık anakütle oluştur. - Karıştırılmış anakütleleri yeniden örnekle ve yeni
test_statistic_shuffleddeğerini hesaplamak içinresample_longtanresample_shortu çıkar. - Her iki test istatistiği dağılımını çizdirmek ve görsel olarak karşılaştırmak için
plot_test_statistic()kullan.
Uygulamalı etkileşimli egzersiz
Bu egzersizi bu örnek kodu tamamlayarak deneyin.
# From the unshuffled groups, compute the test statistic distribution
resample_short = np.random.choice(____, size=500, replace=____)
resample_long = np.random.choice(____, size=500, replace=____)
test_statistic_unshuffled = ____ - ____
# Shuffle two populations, cut in half, and recompute the test statistic
shuffled_half1, shuffled_half2 = shuffle_and_split(____, ____)
resample_half1 = np.random.choice(____, size=500, replace=____)
resample_half2 = np.random.choice(____, size=500, replace=____)
test_statistic_shuffled = resample_half2 - resample_half1
# Plot both the unshuffled and shuffled results and compare
fig = plot_test_statistic(____, label='Unshuffled')
fig = plot_test_statistic(____, label='Shuffled')