Literacy/Fertility डेटा का pairs bootstrap
अभी जो फंक्शन आपने लिखा है, उसका उपयोग करके pairs bootstrap चलाइए और illiteracy/fertility डेटा से slope के estimate का एक histogram प्लॉट कीजिए। साथ ही slope का 95% confidence interval भी रिपोर्ट कीजिए। डेटा आपके पास NumPy arrays illiteracy और fertility में उपलब्ध है।
ध्यान दिलाने के लिए, draw_bs_pairs_linreg() की function signature है draw_bs_pairs_linreg(x, y, size=1), और यह दो वैल्यूज़ रिटर्न करता है: bs_slope_reps और bs_intercept_reps.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Statistical Thinking in Python (Part 2)
अभ्यास निर्देश
- अपने
draw_bs_pairs_linreg()फंक्शन का उपयोग करके slope और intercept के1000bootstrap replicates लीजिए। x-axis का डेटाilliteracyहै और y-axis का डेटाfertilityहै। - Slope के लिए 95% bootstrap confidence interval compute करें और प्रिंट करें।
- Slope replicates का histogram प्लॉट करें और दिखाएँ। अपने axes को लेबल करना न भूलें। यह आपके लिए कर दिया गया है, तो अपना histogram देखने के लिए सबमिट पर क्लिक करें!
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Generate replicates of slope and intercept using pairs bootstrap
bs_slope_reps, bs_intercept_reps = ____
# Compute and print 95% CI for slope
print(np.percentile(____, ____))
# Plot the histogram
_ = plt.hist(bs_slope_reps, bins=50, density=True)
_ = plt.xlabel('slope')
_ = plt.ylabel('PDF')
plt.show()