################## Probabilities #########################
# Factorial
factorial(5)
# Binomial coefficient
# choose(n,k)
n<-49
k<-6
binomial.koeff<-(factorial(n)/(factorial(k)*factorial(n-k)))
binomial.koeff
choose(49,6)
# Binomial distribution
# dbinom(x, size, prob, log = FALSE)
# x: number of ill children, size: total number of children,
# prob: probability that a child fall ill
# P(2 children ill, 3 children healthy)
dbinom(2,5,0.25)
# Graphical representation: relative frequencies in a bar chart
x<-dbinom(c(0,1,2,3,4,5),5,0.25)
names(x) <- c("0", "1","2", "3", "4","5")
barplot(x, main= 'Density Function', xlab='Number of affected children',
ylab='Probability')
x1<-pbinom(c(0,1,2,3,4,5),5,0.25)
names(x1) <- c("0", "1","2", "3", "4","5")
plot(c(0,1,2,3,4,5),x1, type="s",main='Distribution Function',
xlab='Number of affected children', ylab='F')