Frequency distributions
Binomial distribution
size<- 30
prob<- 0.2
N<- seq(0,30, 1)
fn <- dbinom(N,size ,prob)
plot(N,fn,xlab="n",ylab="f(n)",type="l") # pdf
fn2 <- dbinom(N,size ,0.4)
lines(N,fn2, col="red", type="l")
fn3 <- dbinom(N,size ,0.6)
lines(N,fn3, col="blue", type="l")
fn4 <- dbinom(N,size ,0.8)
lines(N,fn4, col="purple", type="l")
Example binomial: we want the probability for fewer than 3 hurricanes:
\[ N \sim Bin(20,0.05) \implies Pr[N<3]=f(0)+f(1)+f(2)\]
Pr<-dbinom(0,20,0.05)+dbinom(1,20,0.05)+dbinom(2,20,0.05)
Pr
## [1] 0.9245163
# we can also use:
Pr<- pbinom(2,20,0.05)
Pr
## [1] 0.9245163
We have: \[ X \sim Bin(25,0.2)\] and \[ Y \sim Bin(20,0.2)\]then, \[X+Y \sim Bin(45,0.2)\]
Pr<-pbinom(10,45,0.2)
Pr
## [1] 0.7204707
Fo rthe Poisson example. we have: \[A \sim Poisson(2.5) \\ B \sim Poisson(3.2) \\ \implies A+B \sim Poisson(5.7) \] The probability for fewer than 3 is then:
Pr<-ppois(3,5.7)
Pr
## [1] 0.1800481
Now, it is important to understand the behavior of the different distributions.
N<- seq(0,30, 1)
fn1 <- dpois(N,1)
plot(N,fn1,xlab="n",ylab="f(n)",type="l") # pdf
fn2 <- dpois(N,5)
lines(N,fn2, col="red", type="l")
fn3 <- dpois(N,10)
lines(N,fn3, col="blue", type="l")
fn4 <- dpois(N,20)
lines(N,fn4, col="purple", type="l")
For the geometric
N<- seq(0,30, 1)
fn1 <- dgeom(N,0.9)
plot(N,fn1,xlab="n",ylab="f(n)",type="l") # pdf
fn2 <- dgeom(N,0.5)
lines(N,fn2, col="red", type="l")
fn3 <- dgeom(N,0.25)
lines(N,fn3, col="blue", type="l")
fn4 <- dgeom(N,0.1)
lines(N,fn4, col="purple", type="l")
And for negative binomial
N<- seq(0,30, 1)
size<- 30
fn1 <- dnbinom(N,size,0.9)
plot(N,fn1,xlab="n",ylab="f(n)",type="l") # pdf
fn2 <- dnbinom(N,size,0.85)
lines(N,fn2, col="red", type="l")
fn3 <- dnbinom(N,size,0.75)
lines(N,fn3, col="blue", type="l")
fn4 <- dnbinom(N,size,0.5)
lines(N,fn4, col="purple", type="l")