Professional Documents
Culture Documents
2 Hypergeometric Distribution
3.5, 3.9 Mean and Variance
Prof. Tesler
Math 186
Winter 2017
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
20
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
c()
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
10
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
0
Index
Prof. Tesler 3.2 Hypergeometric Distribution Math 186 / Winter 2017 2 / 15
30
Sampling from an urn
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
20
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
c()
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
10
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
0
Index
Prof. Tesler 3.2 Hypergeometric Distribution Math 186 / Winter 2017 3 / 15
Sampling with and without replacement
A urn has 1000 balls: 700 green, 300 blue.
Sampling with replacement
Pick one of the 1000 balls. Record color (green or blue).
Put it back in the urn and shake it up.
Again pick one of the 1000 balls and record color.
Repeat n times.
On each draw, the probability of green is 700/1000.
700
The # green balls drawn has a binomial distribution, p = 1000 = .7
Sampling without replacement
Pick one of the 1000 balls, record color, and set it aside.
Pick one of the remaining 999 balls, record color, set it aside.
Pick one of the remaining 998 balls, record color, set it aside.
Repeat n times, never re-using the same ball.
Equivalently, take n balls all at once and count them by color.
The # green balls drawn has a hypergeometric distribution.
Prof. Tesler 3.2 Hypergeometric Distribution Math 186 / Winter 2017 4 / 15
Sampling with and without replacement
A urn has 1000 balls: 700 green, 300 blue.
A sample of 7 balls is drawn.
What is the probability that it has 3 green balls and 4 blue balls?
Notation
Population (full urn) Sample
N balls n balls
K green k green
N − K blue n − k blue
p = K/N p̂ = k/n
Hypergeometric distribution (for sampling w/o replacement)
Draw n balls without replacement.
Let random variable X be the number of green balls drawn.
Its pdf is given by the hypergeometric
distribution
.
K N−K N
P(X = k) =
k n−k n
np(1−p)(N−n)
E(X) = np and Var(X) = (N−1) .
7! 700·699·698
= 3! 4! · 1000·999·998 · 300·299·298·297
997·996·995·994
nd
2 method to compute hypergeometric distribution
7
(700/1000)3 (300/1000)4
≈ 3
Probability with binomial distribution
If the numbers of green, blue, and total balls in the sample are much
smaller than in the urn, the hypergeometric pdf ≈ the binomial pdf.
Prof. Tesler 3.2 Hypergeometric Distribution Math 186 / Winter 2017 8 / 15
Hypergeometric distribution vs. Binomial distribution
p = 0.25, Population size N = 10000
# trials n = 100, p=0.25, # trials n=100, pop. size N=10000, n/N=1.00% n/N = 1% # trials n = 500, p=0.25, # trials n=500, pop. size N=10000, n/N=5.00% n/N = 5%
0.04
!
! !!!
!
!
!
!
! Binomial !!
!
!!!!
!!
! Binomial
!
Hypergeometric ! !
Hypergeometric
0.08
! ! !
! !
! ! !
!
! !
!
!
! !
!
!
!
0.03
! !
Probability density
Probability density
!
!
!
0.06
!
!
!
!
!
! !
!
!
!
0.02
!
!
! !
0.04
!
! !
!
! !
! !
!
!
! !
! !
! !
0.01
! !
!
0.02
!
! !
! !
! !
! !
! ! !
! !
!
! !
! !
! ! !
! ! !
! !
!
! ! !
! !
! !! !
0.00
0.00
!!
! !! !!
! ! !!!! !!!
! !!
!
! ! ! !!!
!! !!
! ! ! ! ! ! ! ! ! ! !!!!!!!!!! !!!!!!!!!
# trials n = 1000, p=0.25, # trials n=1000, pop. size N=10000, n/N=10.00% n/N = 10% # trials n = 5000, p=0.25, # trials n=5000, pop. size N=10000, n/N=50.00% n/N = 50%
0.030
! !!
!
!! !! !! !
!
!
! !
!!! !
! Binomial !
!
!
! !
!
!
!
! Binomial
! !! ! ! !
!!
!
!!
!
!
! Hypergeometric !
!
!
!
! Hypergeometric
0.015
! ! !
!!
!! ! !
!! !!
! !
! ! !
! ! ! !
! !
! ! !
Probability density
Probability density
!
! ! ! !
0.020
!
! ! !
!!
!!
!!
!! !
! ! !!
! !!
! !! !! !
! ! !
! !
!
!
! ! ! ! !
!
! ! ! !
! !
! ! ! !
0.010
! ! !
! !! ! !
! !
! !
!
! !! !!
! ! !
!! !!
! ! !
! ! !
! !
!
! !
! !
! !
! !
! ! ! !
! ! !!
! !
! !!
! ! ! !!
! !
! !! !!
!
0.010
! !
! ! !! !!
!
! ! ! ! !!!
!
0.005
! ! ! !
! ! ! ! !
! ! ! !
! ! !
! ! ! ! ! ! !
! ! ! ! ! !
! ! ! !
! ! ! !
! ! ! !
!! !! ! !
! ! ! !
!! !! ! !
! ! ! !
!! !! ! ! ! !
! !
! ! ! !
!! !! !! ! ! !
!
!! !! !! ! ! !
!
! ! ! !
!! !! !
! ! ! !!
!! !! !
! ! ! !!
! ! ! !
!! !! !! !
! !! !
!
!!! ! !
0.000
0.000
! ! ! ! !
!! !! !! !! !
!
!
!!
!!! !!! !!
!!
!! !
! !!
!!
!!
!!!! !!
!! !!! !!
!!
!!
!!
!! !
!!
!
!!
!!
!!
!!! !! !!
!!
!! !!
!! !
!!
! !!
!!
!
!
!!!! !!!!!
!!!!!!!!!!! !
!!
!!
!! !
!!
!! !
!!
!! !
!!
!!
!!
!
!!!!!!!!!!!!!!!! !!!!! !
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!
!!
!
!
!!
!
!
!!
!
!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
! !!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!
!
!!
!
!
!!
!
!
!!
!
!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
!!
200 220 240 260 280 300 1150 1200 1250 1300 1350
k k
30
Sampling without replacement from an urn with multiple colors
Illustrated for 3 colors, but works for any number of colors
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
20
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
c()
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
10
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
0
An urn has 1000 balls: 500 red, 300 blue, 200 green.
Draw a sample of 10 balls without replacement.
What is the probability
0
it has 2 red,
10 20
3 blue,
30
and 540green balls?
Index
500 300 200
# samples with 2 red, 3 blue, 5 green
= 2 1000 3
5 ≈ 0.00535
# samples of size 10 10
20
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
c()
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
10
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
0
If the sample size is much smaller than the population size, can
approximate by binomial distribution.
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
20
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
c()
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
10
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
0
2 K K2 K(N − K)
2
Var(Xi ) = E(Xi ) − (E(Xi )) = p − p = − 2 = 2
.
N N N
Var(X) = Var(X1 + · · · + Xn )
X n X
= Var(X ) + 2 Cov(Xi , Xj )
| {z i} | {z }
i=1 16i<j6n
|{z} = K(N−K)
2 | {z } =
K(K−N)
N N 2 (N−1)
n terms n
terms
2
N−n
Var(X) = np(1 − p)
N−1