開始使用免費開始

喙長與喙深的比例

前面的線性迴歸揭示了喙部幾何的有趣資訊。1975 年與 2012 年的斜率相同,顯示每增加 1 毫米的喙長,兩個年份的喙深都約增加 0.5 毫米。不過,如果我們關心的是喙形狀,就該比較喙長與喙深的「比例」。現在就來做這個比較。

記住,資料分別儲存在 bd_1975bd_2012bl_1975bl_2012

本練習屬於課程

Statistical Thinking in 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)
編輯並執行程式碼