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

Linear regressions

1975 और 2012 दोनों डेटा के लिए एक linear regression चलाएँ. फिर, regression पैरामीटर्स के लिए pairs bootstrap estimates करें. Regression line के slope और intercept पर 95% confidence intervals रिपोर्ट करें.

आप draw_bs_pairs_linreg() फंक्शन का उपयोग करेंगे, जिसे आपने अध्याय 2 में लिखा था.

याद दिलाने के लिए, इसका call signature है draw_bs_pairs_linreg(x, y, size=1), और यह bs_slope_reps और bs_intercept_reps रिटर्न करता है. Beak length डेटा bl_1975 और bl_2012 में है, और beak depth डेटा bd_1975 और bd_2012 में स्टोर है.

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

Statistical Thinking in Python (Part 2)

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

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

  • 1975 और 2012 दोनों डेटासेट्स के लिए slope और intercept compute करें.
  • अपनी draw_bs_pairs_linreg() फंक्शन का उपयोग करके linear regressions के लिए 1000 pairs bootstrap samples प्राप्त करें.
  • Slopes और intercepts के लिए 95% confidence intervals compute करें.

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

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

# Compute the linear regressions
slope_1975, intercept_1975 = ____
slope_2012, intercept_2012 = ____

# Perform pairs bootstrap for the linear regressions
bs_slope_reps_1975, bs_intercept_reps_1975 = \
        ____
bs_slope_reps_2012, bs_intercept_reps_2012 = \
        ____

# Compute confidence intervals of slopes
slope_conf_int_1975 = ____
slope_conf_int_2012 = ____
intercept_conf_int_1975 = ____

intercept_conf_int_2012 = ____


# Print the results
print('1975: slope =', slope_1975,
      'conf int =', slope_conf_int_1975)
print('1975: intercept =', intercept_1975,
      'conf int =', intercept_conf_int_1975)
print('2012: slope =', slope_2012,
      'conf int =', slope_conf_int_2012)
print('2012: intercept =', intercept_2012,
      'conf int =', intercept_conf_int_2012)
कोड संपादित करें और चलाएँ