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

Bootstrap और Standard Error

एक National Park की कल्पना कीजिए जहाँ पार्क रेंजर्स ट्रेल्स की देखभाल के लिए रोज़ हाइक करते हैं. वे हमेशा एक ही रास्ता नहीं लेते, लेकिन वे अपनी अंतिम दूरी और समय दर्ज करते हैं. हम एक रेंजर के सीमित डेटा सैंपल से रोज़ाना तय की गई दूरी में होने वाले बदलावों का एक सांख्यिकीय मॉडल बनाना चाहते हैं.

आपका लक्ष्य है bootstrap resampling का उपयोग करना, हर resample के लिए एक mean निकालना, उन means का एक डिस्ट्रीब्यूशन बनाना, और फिर standard error की गणना करना ताकि sample statistic को population statistic के अनुमानक के रूप में उपयोग करने में मौजूद "अनिश्चितता" को मापा जा सके.

500 स्वतंत्र distance मापों वाला पहले से लोड किया गया sample_data array उपयोग करें. फिलहाल, इस लेसन को सरल रखने के लिए हम simulated डेटा सेट का उपयोग कर रहे हैं. आगे चलकर, हम अधिक वास्तविक डेटा देखेंगे.

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

Python में Linear Modeling परिचय

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

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

  • sample_data को population के लिए मॉडल के रूप में असाइन करें.

  • num_resamples बार iterate करें:

    • हर बार np.random.choice() का उपयोग करके population_model से size=resample_size का bootstrap_sample बनाएँ और replace=True निर्दिष्ट करें.
    • हर बार sample mean की गणना करें और उसे स्टोर करें.
  • bootstrap_means का np.mean() और np.std() निकालें और प्रिंट करें.

  • पहले से परिभाषित plot_data_hist() का उपयोग करें और bootstrap_means डिस्ट्रीब्यूशन को विज़ुअलाइज़ करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Use the sample_data as a model for the population
population_model = ____

# Resample the population_model 100 times, computing the mean each sample
for nr in range(num_resamples):
    bootstrap_sample = np.random.____(population_model, size=____, replace=____)
    bootstrap_means[nr] = np.____(bootstrap_sample)

# Compute and print the mean, stdev of the resample distribution of means
distribution_mean = np.mean(____)
standard_error = np.std(____)
print('Bootstrap Distribution: center={:0.1f}, spread={:0.1f}'.format(____, ____))

# Plot the bootstrap resample distribution of means
fig = plot_data_hist(____)
कोड संपादित करें और चलाएँ