axjack's blog

### axjack is said to be an abbreviation for An eXistent JApanese Cool Klutz ###

超幾何分布

何度やっても忘れるのでブログに書いて覚えよう。

超幾何分布の確率質量関数


\displaystyle P(X=x) = f(x; N,M,n) = \frac{ \binom{M}{x} \binom{N-M}{n-x} } { \binom{N}{n} }

計算例

その1

男50人女50人から10人を選ぶ。10人のうち男3人女7人となる確率pは、超幾何分布を用いて


\displaystyle p = \frac{ \binom{50}{3} \binom{50}{7} }{ \binom{100}{10}}

その2

統計検定準一級2017年問10より引用。表の80人から30人を無作為抽出する。その30人のうち男性かつ就職している人数Xは超幾何分布に従う。

就職 非就職
男性 38 3 41
女性 30 9 39
68 12 80
  • 80人から30人を選ぶ
  • 「男性かつ就職」である人:38
  • 「男性かつ就職」でない人:80-38 = 42

と整理して、


\displaystyle P(X=x) = \frac{ \binom{38}{x} \binom{42}{30-x} }{ \binom{80}{30} }

となる。

その3

同じ表を用いて、80人から20人を無作為抽出する。その20人のうち「女性かつ非就職」な人数Xは超幾何分布に従う。

  • 80人から20人を選ぶ
  • 「女性かつ非就職」である人:9
  • 「女性かつ非就職」でない人:80-9 = 71

と整理して、


\displaystyle P(X=x) = \frac{ \binom{9}{x} \binom{71}{20-x} }{ \binom{80}{20} }

となる。

Rで計算する

choose関数で立てた式が超幾何分布の質量関数dhyperと同じことを確認。

# その1
> choose(50,3)*choose(50,7)/choose(100,10)
[1] 0.1130964
> dhyper(3,50,50,10)
[1] 0.1130964

dhpyer(x,m,n,k)の引数*1は、

  • x: vector of quantiles representing the number of white balls drawn without replacement from an urn which contains both black and white balls.
  • m: the number of white balls in the urn.
  • n: the number of black balls in the urn.
  • k:the number of balls drawn from the urn.
axjack is said to be an abbreviation for An eXistent JApanese Cool Klutz.