建立抽樣分配

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...