开始使用免费开始使用

喙长与喙深之比

线性回归揭示了喙部几何的一些有趣信息。1975 年和 2012 年的斜率相同,说明在这两年里,喙长每增加 1 毫米,喙深大约增加 0.5 毫米。不过,如果我们更关注喙的形状,就需要比较喙长与喙深的「比值」。我们就来做这个比较。

请记住,数据存放在 bd_1975bd_2012bl_1975bl_2012 中。

本练习是课程的一部分

Python 统计思维(第 2 部分)

查看课程

练习说明

  • 分别为 1975 年和 2012 年的每只鸟构建喙长与喙深之比的数组。
  • 计算 1975 年和 2012 年的长度/深度比的平均值。
  • 使用您编写的 draw_bs_reps() 函数,为 1975 年和 2012 年的平均比值各生成 10,000 个自助法重复样本。
  • 获取 1975 年和 2012 年长度/深度比的 99% 自助法置信区间。
  • 打印结果。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Compute length-to-depth ratios
ratio_1975 = ____
ratio_2012 = ____

# Compute means
mean_ratio_1975 = ____
mean_ratio_2012 = ____

# Generate bootstrap replicates of the means
bs_replicates_1975 = ____
bs_replicates_2012 = ____

# Compute the 99% confidence intervals
conf_int_1975 = ____
conf_int_2012 = ____

# Print the results
print('1975: mean ratio =', mean_ratio_1975,
      'conf int =', conf_int_1975)
print('2012: mean ratio =', mean_ratio_2012,
      'conf int =', conf_int_2012)
编辑并运行代码