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_speedscompute करें.np.mean()का उपयोग करकेresample_speedsसेspeed_estimatecompute करें.np.percentile()को[5, 95]के साथ उपयोग करकेresample_speedsकेpercentilescompute करें, जो confidence interval की boundaries तय करते हैं.axis.hist()का उपयोग करकेresample_speedsplot करें, और 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()