中心極限定理

Python を使った統計学入門

Maggie Matsui

Content Developer, DataCamp

サイコロを5回振る

die = pd.Series([1, 2, 3, 4, 5, 6])

# Roll 5 times samp_5 = die.sample(5, replace=True) print(samp_5)
array([3, 1, 4, 1, 1])
np.mean(samp_5)
2.0

六面体のサイコロ

Python を使った統計学入門

サイコロを5回振る

# Roll 5 times and take mean
samp_5 = die.sample(5, replace=True)
np.mean(samp_5)
4.4
samp_5 = die.sample(5, replace=True)
np.mean(samp_5)
3.8
Python を使った統計学入門

サイコロを5回振るのを10セット繰り返す

10セット繰り返す:

  • 5回振る
  • 平均を求める
sample_means = []

for i in range(10):
samp_5 = die.sample(5, replace=True) sample_means.append(np.mean(samp_5))
print(sample_means)
[3.8, 4.0, 3.8, 3.6, 3.2, 4.8, 2.6,
3.0, 2.6, 2.0]
Python を使った統計学入門

標本分布

標本平均の標本分布

10個の標本平均のヒストグラム

Python を使った統計学入門

100個の標本平均

sample_means = []
for i in range(100):
    sample_means.append(np.mean(die.sample(5, replace=True)))

100個の標本平均のヒストグラム

Python を使った統計学入門

1000個の標本平均

sample_means = []
for i in range(1000):
    sample_means.append(np.mean(die.sample(5, replace=True)))

1000個の標本平均のヒストグラム

Python を使った統計学入門

中心極限定理

試行回数が増えるほど、統計量の標本分布は正規分布に近づく。

10、100、1000の標本平均のヒストグラム。標本平均の数が多いほど、よりベルカーブ状の分布になる

* 標本はランダムかつ独立事象である

Python を使った統計学入門

標準偏差とCLT

sample_sds = []
for i in range(1000):
  sample_sds.append(np.std(die.sample(5, replace=True)))

5回のサイコロ振りの1000個の標本標準偏差の分布

Python を使った統計学入門

比率とCLT

sales_team = pd.Series(["Amir", "Brian", "Claire", "Damian"])

sales_team.sample(10, replace=True)
array(['Claire', 'Damian', 'Brian', 'Damian', 'Damian', 'Amir', 'Amir', 'Amir', 
      'Amir', 'Damian'], dtype=object)
sales_team.sample(10, replace=True)
array(['Brian', 'Amir', 'Brian', 'Claire', 'Brian', 'Damian', 'Claire', 'Brian', 
      'Claire', 'Claire'], dtype=object)
Python を使った統計学入門

割合の標本分布

標本比率の分布も正規分布に見える

Python を使った統計学入門

標本分布の平均

# Estimate expected value of die
np.mean(sample_means)
3.48
# Estimate proportion of "Claire"s
np.mean(sample_props)
0.26

中央に破線が引かれた標本平均の標本分布

  • 未知の基礎分布の特性を推定する
  • 大規模な集団の特性の推定がより容易に
Python を使った統計学入門

練習しましょう!

Python を使った統計学入門

Preparing Video For Download...