開始使用免費開始

子代與親代資料的 Pearson 相關

Pearson 相關係數可用來評估親代喙部深度在子代中的遺傳強度。請計算 G. scandens 的親代與子代喙部深度之間的 Pearson 相關係數;G. fortis 也同樣計算。接著,使用你在上一個練習寫的函式,透過成對自助法(pairs bootstrap)計算 95% 信賴區間。

提醒你,資料已存於 bd_parent_scandensbd_offspring_scandensbd_parent_fortisbd_offspring_fortis

本練習屬於課程

Statistical Thinking in Python(第 2 部分)

檢視課程

練習說明

  • 使用你在本課程前傳中撰寫的 pearson_r() 函式(https://campus.datacamp.com/courses/statistical-thinking-in-python-part-1/quantitative-exploratory-data-analysis?ex=15),為 G. scandensG. fortis 計算 Pearson 相關係數。
  • 使用你在上一題撰寫的 draw_bs_pairs() 函式,為 G. scandensG. fortis 取得 1000 組 Pearson 相關係數的成對自助法複本。
  • 使用你的自助法複本計算兩者的 95% 信賴區間。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Compute the Pearson correlation coefficients
r_scandens = ____
r_fortis = ____

# Acquire 1000 bootstrap replicates of Pearson r
bs_replicates_scandens = ____

bs_replicates_fortis = ____


# Compute 95% confidence intervals
conf_int_scandens = ____
conf_int_fortis = ____

# Print results
print('G. scandens:', r_scandens, conf_int_scandens)
print('G. fortis:', r_fortis, conf_int_fortis)
編輯並執行程式碼