点推定の相対誤差

Pythonで学ぶサンプリング

James Chapman

Curriculum Manager, DataCamp

標本サイズは行数

len(coffee_ratings.sample(n=300))
300
len(coffee_ratings.sample(frac=0.25))
334
Pythonで学ぶサンプリング

さまざまな標本サイズ

coffee_ratings['total_cup_points'].mean()
82.15120328849028
coffee_ratings.sample(n=10)['total_cup_points'].mean()
83.027
coffee_ratings.sample(n=100)['total_cup_points'].mean()
82.4897
coffee_ratings.sample(n=1000)['total_cup_points'].mean()
82.1186
Pythonで学ぶサンプリング

相対誤差

母集団パラメータ:

population_mean = coffee_ratings['total_cup_points'].mean()

点推定:

sample_mean = coffee_ratings.sample(n=sample_size)['total_cup_points'].mean()

相対誤差(%):

rel_error_pct = 100 * abs(population_mean-sample_mean) / population_mean
Pythonで学ぶサンプリング

相対誤差 vs. 標本サイズ

import matplotlib.pyplot as plt
errors.plot(x="sample_size", 
            y="relative_error", 
            kind="line")
plt.show()

特性:

  • 小標本で特にノイズが大きい
  • 振幅は最初急で、その後なだらか
  • 標本サイズ=母集団で相対誤差は0に近づく

相対誤差と標本サイズの折れ線グラフ。

Pythonで学ぶサンプリング

演習に進みましょう!

Pythonで学ぶサンプリング

Preparing Video For Download...