開始使用免費開始

計算相對誤差

你抽取的樣本大小會影響點估計對應母體參數的準確程度。以計算樣本平均數為例,你會希望它接近母體平均數。不過,如果樣本太小,就不一定辦得到。

評估準確度最常見的指標是「相對誤差」。也就是母體參數與點估計之間的絕對差,再除以母體參數。有時會以百分比呈現。

已提供 attrition_popmean_attrition_popattrition_popAttrition 欄位平均數);pandas 已載入為 pd

本練習屬於課程

Python 中的抽樣

檢視課程

動手互動練習

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

# Generate a simple random sample of 50 rows, with seed 2022
attrition_srs50 = ____

# Calculate the mean employee attrition in the sample
mean_attrition_srs50 = ____

# Calculate the relative error percentage
rel_error_pct50 = ____

# Print rel_error_pct50
print(rel_error_pct50)
編輯並執行程式碼