开始使用免费开始使用

水流效应如何随泳道位置变化?

为了量化泳道编号对成绩的影响,请对 f_13lanes 的数据执行线性回归。进行配对自举计算以获得 95% 置信区间。最后,绘制回归图。数组 lanesf_13 已在您的命名空间中。

请注意,我们也可以计算平均相对差的误差条并在回归中使用,但这超出了本课程的范围。

本练习是课程的一部分

统计思维案例研习

查看课程

练习说明

  • 使用 np.polyfit() 计算 f_13 相对于 lanes 直线的斜率和截距。
  • 使用 dcst.draw_bs_pairs_linreg() 获取斜率和截距的 10,000 个自举重复,并分别存储在 bs_reps_slopebs_reps_int 中。
  • 使用这些自举重复计算斜率的 95% 置信区间。
  • 将斜率和 95% 置信区间打印到屏幕上。此步骤已为您完成。
  • 使用 np.array() 生成用于绘制自举直线的 x 值。x 应从 18
  • 图中已包含数据。请写一个 for 循环,使用关键字参数 color='red'alpha=0.2linewidth=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()
编辑并运行代码