Statistical Thinking in Python (Part 2)
Justin Bois
Lecturer at the California Institute of Technology
np.arange(7)
array([0, 1, 2, 3, 4, 5, 6])
inds = np.arange(len(total_votes))
bs_inds = np.random.choice(inds, len(inds))
bs_total_votes = total_votes[bs_inds] bs_dem_share = dem_share[bs_inds]
bs_slope, bs_intercept = np.polyfit(bs_total_votes, bs_dem_share, 1)
bs_slope, bs_intercept
(3.9053605692223672e-05, 40.387910131803025)
np.polyfit(total_votes, dem_share, 1) # fit of original
array([ 4.03707170e-05, 4.01139120e+01])
Statistical Thinking in Python (Part 2)