Test Statistics और Effect Size
हम bootstrap resampling के साथ linear relationships को कैसे explore कर सकते हैं? चलिए फिर ट्रेल पर लौटते हैं! हर hike एक बिंदु के रूप में प्लॉट की गई है, जहाँ आप कुल तय की गई दूरी और बीता हुआ समय के बीच एक linear संबंध देख सकते हैं। अगर हम तय की गई दूरी को बीते हुए समय का "effect" मानें, तो हम linear regression और statistical inference के बीच की कड़ी को explore कर सकते हैं.
इस अभ्यास में, आप डेटा को दो populations या "categories" में बाँटेंगे: early times और late times. फिर आप हर population के भीतर कुल दूरी के बीच के अंतर को देखेंगे। यही अंतर हमारा "test statistic" होगा, और इसका distribution यह जाँचेगा कि समय के आधार पर दूरी को अलग करने का क्या प्रभाव पड़ता है.

यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Linear Modeling परिचय
अभ्यास निर्देश
numpyकी "logical indexing" का उपयोग करें, जैसेsample_distances[sample_times < 5], ताकि sampledistancesको early और late time populations में अलग किया जा सके.np.random.choice()का उपयोगreplacement=Trueके साथ करें, और दोनों time bins के लिए एक-एकresampleबनाएँ.test_statisticarray कोresample_long - resample_shortके रूप में compute करें, औरnp.mean(),np.std()से effect size और uncertainty निकालकर print करें.test_statisticdistribution को plot करें, इसके लिए पहले से परिभाषितfig = plot_test_statistic()का उपयोग करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Create two poulations, sample_distances for early and late sample_times.
# Then resample with replacement, taking 500 random draws from each population.
group_duration_short = sample_distances[____ < 5]
group_duration_long = sample_distances[____ > 5]
resample_short = np.random.choice(____, size=500, replace=____)
resample_long = np.random.choice(____, size=500, replace=____)
# Difference the resamples to compute a test statistic distribution, then compute its mean and stdev
test_statistic = resample_long - resample_short
effect_size = np.mean(____)
standard_error = np.std(____)
# Print and plot the results
print('Test Statistic: mean={:0.2f}, stdev={:0.2f}'.format(____, ____))
fig = plot_test_statistic(____)