rm(list=ls(all=TRUE))
cat("\014")
options(digits=12)
options(scipen=10)

success=10 # number of success
failure=8 # number of failure
drawn=6 # sample size
x=seq(0,6,by=1)
h.x=dhyper(x,success,failure,drawn)
table=data.frame(x,h.x)
table

h=function(x,N,n,k) dhyper(x,k,N-k,n)
h(0,18,6,10)
h(1,18,6,10)
h(2,18,6,10)
h(3,18,6,10)
h(4,18,6,10)

c=function(n,r) factorial(n)/(factorial(r)*factorial(n-r))
c(5,2)
h=function(x,N,n,k) c(k,x)*c(N-k,n-x)/c(N,n)
h(0,18,6,10)
h(1,18,6,10)
h(2,18,6,10)
h(3,18,6,10)
h(4,18,6,10)

