機率分配與情境:二項分配

Statistical Thinking in Python (Part 1)

Justin Bois

Teaching Professor at the California Institute of Technology

機率質量函數(PMF)

  • 離散結果的機率集合
Statistical Thinking in Python (Part 1)

離散均勻 PMF

第 3 章圖 3-3.004

Statistical Thinking in Python (Part 1)

機率分配

  • 對結果的數學描述
Statistical Thinking in Python (Part 1)

離散均勻分配:情境

擲一顆公平骰子的結果是:

  • 離散。
  • 均勻分配。
Statistical Thinking in Python (Part 1)

二項分配:情境

  • 在 n 次伯努利試驗中,成功機率為 p,成功次數 r 服從二項分配。
  • 擲硬幣 4 次,正面機率 0.5,正面次數 r 服從二項分配。
Statistical Thinking in Python (Part 1)

從二項分配取樣

rng.binomial(4, 0.5)
2
rng.binomial(4, 0.5, size=10)
array([4, 3, 2, 1, 1, 0, 3, 2, 3, 0])
Statistical Thinking in Python (Part 1)

二項 PMF

samples = rng.binomial(60, 0.1, size=10000)
n = 60
p = 0.1

第 3 章圖 3-3.019

Statistical Thinking in Python (Part 1)

二項 CDF

import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
x, y = ecdf(samples)
_ = plt.plot(x, y, marker='.', linestyle='none')
plt.margins(0.02)
_ = plt.xlabel('number of successes')
_ = plt.ylabel('CDF')
plt.show()
Statistical Thinking in Python (Part 1)

二項 CDF

第 3 章圖 3-3.022

Statistical Thinking in Python (Part 1)

一起來練習吧!

Statistical Thinking in Python (Part 1)

Preparing Video For Download...