构建抽样分布

Python 抽样

James Chapman

Curriculum Manager, DataCamp

相同代码,不同结果

coffee_ratings.sample(n=30)['total_cup_points'].mean()
82.53066666666668
coffee_ratings.sample(n=30)['total_cup_points'].mean()
81.97566666666667
coffee_ratings.sample(n=30)['total_cup_points'].mean()
82.68
coffee_ratings.sample(n=30)['total_cup_points'].mean()
81.675
Python 抽样

相同代码,重复 1000 次

mean_cup_points_1000 = []

for i in range(1000): mean_cup_points_1000.append( coffee_ratings.sample(n=30)['total_cup_points'].mean() )
print(mean_cup_points_1000)
[82.11933333333333, 82.55300000000001, 82.07266666666668, 81.76966666666667, 
...
 82.74166666666666, 82.45033333333335, 81.77199999999999, 82.8163333333333]
Python 抽样

样本量为 30 的样本均值分布

import matplotlib.pyplot as plt
plt.hist(mean_cup_points_1000, bins=30)
plt.show()

"抽样分布"是点估计重复值的分布。

样本均值的直方图。

Python 抽样

不同的样本量

样本量:6

样本量为 6 的样本均值直方图。

样本量:150

样本量为 150 的样本均值直方图。

Python 抽样

开始练习吧!

Python 抽样

Preparing Video For Download...