水流效应如何随泳道位置变化?
为了量化泳道编号对成绩的影响,请对 f_13 与 lanes 的数据执行线性回归。进行配对自举计算以获得 95% 置信区间。最后,绘制回归图。数组 lanes 和 f_13 已在您的命名空间中。
请注意,我们也可以计算平均相对差的误差条并在回归中使用,但这超出了本课程的范围。
本练习是课程的一部分
统计思维案例研习
练习说明
- 使用
np.polyfit()计算f_13相对于lanes直线的斜率和截距。 - 使用
dcst.draw_bs_pairs_linreg()获取斜率和截距的 10,000 个自举重复,并分别存储在bs_reps_slope和bs_reps_int中。 - 使用这些自举重复计算斜率的 95% 置信区间。
- 将斜率和 95% 置信区间打印到屏幕上。此步骤已为您完成。
- 使用
np.array()生成用于绘制自举直线的 x 值。x应从1到8。 - 图中已包含数据。请写一个
for循环,使用关键字参数color='red'、alpha=0.2和linewidth=0.5,向图中添加 100 条自举直线。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Compute the slope and intercept of the frac diff/lane curve
____, ____ = ____
# Compute bootstrap replicates
bs_reps_slope, bs_reps_int = ____
# Compute 95% confidence interval of slope
conf_int = ____
# Print slope and confidence interval
print("""
slope: {0:.5f} per lane
95% conf int: [{1:.5f}, {2:.5f}] per lane""".format(slope, *conf_int))
# x-values for plotting regression lines
x = ____
# Plot 100 bootstrap replicate lines
for i in ____:
_ = ____(____, ____[i] * ____ + ____[i],
color='red', alpha=0.2, linewidth=0.5)
# Update the plot
plt.draw()
plt.show()