標本分布を作る

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で学ぶサンプリング

Vamos praticar!

Pythonで学ぶサンプリング

Preparing Video For Download...