计算相对误差
您抽取的样本大小会影响点估计反映总体参数的准确程度。例如,当您计算样本均值时,希望它接近总体均值。然而,如果样本太小,往往达不到这一点。
评估准确度最常用的指标是「相对误差」。它等于总体参数与点估计之差的绝对值,再除以总体参数。有时也会以百分比形式表示。
已提供 attrition_pop 和 mean_attrition_pop(attrition_pop 的 Attrition 列的均值);已将 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)