重複抽樣
當你計算樣本平均數這類的點估計時,結果會取決於樣本中包含的列。因此答案帶有隨機性。為了量化這種隨機性所造成的變動,你可以建立許多樣本,並為每個樣本計算樣本平均數(或其他統計量)。
attrition_pop 可用;pandas 與 matplotlib.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])