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

Bootstrap को विज़ुअलाइज़ करें

इस लेसन में जहाँ हमने छोड़ा था, वहीं से आगे बढ़ते हैं. आइए bootstrap resampling से अनुमानित speeds के bootstrap distribution को विज़ुअलाइज़ करें. यहाँ हर सैंपल पर slope के लिए least-squares fit compute किया गया है ताकि हमारी slope estimation में variation या uncertainty को परखा जा सके.

शुरू करने के लिए, हमने एक फंक्शन compute_resample_speeds(distances, times) प्रीलोड किया है, जो speed sample distribution generate करने की computation करता है.

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

Python में Linear Modeling परिचय

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

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

  • compute_resample_speeds(distances, times) (pre-defined) का उपयोग करके resample_speeds compute करें.
  • np.mean() का उपयोग करके resample_speeds से speed_estimate compute करें.
  • np.percentile() को [5, 95] के साथ उपयोग करके resample_speeds के percentiles compute करें, जो confidence interval की boundaries तय करते हैं.
  • axis.hist() का उपयोग करके resample_speeds plot करें, और bins को hist_bin_edges से specify करें.
  • axis.axvline का उपयोग करते हुए, चार्ट पर confidence interval की boundaries मार्क करने के लिए percentiles के सही दो indices specify करें.

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

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

# Create the bootstrap distribution of speeds
resample_speeds = compute_resample_speeds(____, ____)
speed_estimate = np.mean(____)
percentiles = np.percentile(____, [5, 95])

# Plot the histogram with the estimate and confidence interval
fig, axis = plt.subplots()
hist_bin_edges = np.linspace(0.0, 4.0, 21)
axis.hist(____, ____, color='green', alpha=0.35, rwidth=0.8)
axis.axvline(speed_estimate, label='Estimate', color='black')
axis.axvline(percentiles[____], label=' 5th', color='blue')
axis.axvline(percentiles[____], label='95th', color='blue')
axis.legend()
plt.show()
कोड संपादित करें और चलाएँ