开始使用免费开始使用

重复抽样

当您计算样本均值等点估计时,结果取决于样本中包含的行。因此,答案中会带有一定的随机性。为了量化这种随机性带来的变动,您可以创建许多样本,并对每个样本计算样本均值(或其他统计量)。

已提供 attrition_poppandasmatplotlib.pyplot 已按常用别名加载。

本练习是课程的一部分

Python 抽样

查看课程

交互式实操练习

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

# Create an empty list
____
# Loop 500 times to create 500 sample means
____:
	mean_attritions.append(
    	attrition_pop.sample(n=60)['Attrition'].mean()
	)
  
# Print out the first few entries of the list
print(mean_attritions[0:5])
编辑并运行代码