शुरू करेंमुफ़्त में शुरू करें

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 यह जाँचेगा कि समय के आधार पर दूरी को अलग करने का क्या प्रभाव पड़ता है.

ch04_ex11_fig03.png

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में Linear Modeling परिचय

पाठ्यक्रम देखें

अभ्यास निर्देश

  • numpy की "logical indexing" का उपयोग करें, जैसे sample_distances[sample_times < 5], ताकि sample distances को early और late time populations में अलग किया जा सके.
  • np.random.choice() का उपयोग replacement=True के साथ करें, और दोनों time bins के लिए एक-एक resample बनाएँ.
  • test_statistic array को resample_long - resample_short के रूप में compute करें, और np.mean(), np.std() से effect size और uncertainty निकालकर print करें.
  • test_statistic distribution को 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(____)
कोड संपादित करें और चलाएँ