1. Calculate the probability

[Example] Transplant center of General Hospital conducted 56 liver transplantation over the past six month and the 5-year surival rate is 75%.

  1. What is the probability that 40 patients live longer than 5 years?

    \[ Pr(Y=40)= \frac{56!}{40!(56-40)!} 0.76^{40}(1-0.75)^{56-40}. \]

# by formula
n = 56
p = 0.75
y = 40
rlt = factorial(n)/(factorial(y)*factorial(n-y))*p^y*(1-p)^(n-y)
rlt
## [1] 0.09752024
# by R function
dbinom(40,56,0.75)
## [1] 0.09752024
  1. What is the probability that more than 40 patients live longer than 5 years? \[ Pr(Y>40)= P(Y=41) + P(Y=42) + \ldots + P(Y=56) \]
n = 56
p = 0.75
rlt  = 0
for (y in 41:56){
  rlt = rlt +factorial(n)/(factorial(y)*factorial(n-y))*p^y*(1-p)^(n-y)
}
rlt
## [1] 0.685339
# by formula
1-pbinom(40,56,0.75)
## [1] 0.685339

2. Probability plots

# Probability plot with fixed $n=5$ and varying $p$.

n = 5
y = 0:5
data.frame(y        = y,
           prob_0.2 = dbinom(y,n,p=0.2),
           prob_0.4 = dbinom(y,n,p=0.4),
           prob_0.6 = dbinom(y,n,p=0.6),
           prob_0.8 = dbinom(y,n,p=0.6))
##   y prob_0.2 prob_0.4 prob_0.6 prob_0.8
## 1 0  0.32768  0.07776  0.01024  0.01024
## 2 1  0.40960  0.25920  0.07680  0.07680
## 3 2  0.20480  0.34560  0.23040  0.23040
## 4 3  0.05120  0.23040  0.34560  0.34560
## 5 4  0.00640  0.07680  0.25920  0.25920
## 6 5  0.00032  0.01024  0.07776  0.07776
par(mfrow=c(2,2)) 
plot(y, dbinom(y,n,p=0.2),main= "p=0.2",type="h",xlab="number of trials",ylab="probability")
plot(y, dbinom(y,n,p=0.4),main= "p=0.4",type="h",xlab="number of trials",ylab="probability")
plot(y, dbinom(y,n,p=0.6),main= "p=0.6",type="h",xlab="number of trials",ylab="probability")
plot(y, dbinom(y,n,p=0.8),main= "p=0.8",type="h",xlab="number of trials",ylab="probability")

# Probability plot with fixed $p=0.5$ and varying $n$.

p=0.5

par(mfrow=c(2,2)) 
for (n in c(5, 10, 30, 100)){
  y= 0:n
  plot(y, dbinom(y,n,p),main= paste("n=",n,sep=""),type="h",xlab="number of trials",ylab="probability")
}

# Probability plot with fixed $p=0.2$ and varying $n$.

p=0.1

par(mfrow=c(2,2)) 
for (n in c(5, 25, 50, 100)){
  y= 0:n
  plot(y, dbinom(y,n,p),main= paste("n=",n,sep=""),type="h",xlab="number of trials",ylab="probability")
}

Binomial distribution can be approximated by a normal distribution when \(n\) is large, i.e., \(n \pi \geq 5\) and \(n(1- \pi) \geq 5\).