n=10
p=0.1
q=1-p

x=0:10
y=dbinom(x,n,p)

plot(x,y,type="h",lwd=2,col="red")

mu=n*p
s=sqrt(n*p*q)

plot(x,y,type="h",lwd=2,col="red")
xx=seq(0,10,length=200)
yy=dnorm(xx,mu,s)
lines(xx,yy,lwd=2,col="blue")

plot of chunk unnamed-chunk-1

pbinom(1,n,p)
## [1] 0.7361
pnorm(1,mu,s)
## [1] 0.5
n=10
p=0.5
q=0.5

x=0:10
y=dbinom(x,n,p)

plot(x,y,type="h",lwd=2,col="purple")
mu=n*p
s=sqrt(n*p*q)
xx=seq(0,10,length=200)
yy=dnorm(xx,mu,s)
lines(xx,yy,lwd=2,col="green")

plot of chunk unnamed-chunk-1

pbinom(4,n,p)
## [1] 0.377
pnorm(4,mu,s)
## [1] 0.2635
n=100
p=0.5
q=0.5

x=0:100
y=dbinom(x,n,p)

plot(x,y,type="h",lwd=2,col="yellow")
mu=n*p
s=sqrt(n*p*q)
xx=seq(0,100,length=200)
yy=dnorm(xx,mu,s)
lines(xx,yy,lwd=2,col="green")

plot of chunk unnamed-chunk-1

pbinom(60,n,p)
## [1] 0.9824
pnorm(60,mu,s)
## [1] 0.9772
n=50
p=0.4
q=1-p

pbinom(15,n,p)
## [1] 0.0955
mu=n*p
s=sqrt(n*p*q)

pnorm(15,mu,s)
## [1] 0.07446
pnorm(15.5,mu,s)
## [1] 0.09697