#Make a plot that demonstrates that a Poisson distribution is a good approximation
#of a binomial distribution when n >> 0 and p << 1. To do this, choose an appropriate
#set of n and p values, like slide 6 of Ppt170927. But note that both distributions
#in this assignment are discrete distributions - you should think that what would be a
#good plotting type for these. Make a single file that contains: all the 'code' you used
#for this (it is fine to copy all the related from the console); the plot you made as a
#pasted picture (5 points); including a legend + plot title + labeled axes that were
#inserted into your graphic using R (2 points); and an accompanying text explanation of why
#this plot demonstrates that a Poisson distribution is a good approximation of a binomial
#distribution when n >> 0 and p << 1. Make the explanation understandable to people who only
#see your plot and explanation - assume that those people do not see your R scripts
#(3 points).
x=0:200
plot(x,dbinom(x,200,0.2),type='l',col="orange",lwd=1,xlab="X",ylab="Probability",main="Binomial&Poisson Distributions:n=200,p=0.2",xlim=c(0,80))
points(x,dpois(x,200*0.2),type='h',col='green',lwd=1,xlab="X",ylab="Probability")
legend(50,0.06,c('Binomial','Poisson'),col=c('orange','green'),lwd=2)

#The mean of the binomial distribution can be described as n*p. For the Poisson distribution,
#lambda is the mean (np). We can set n*p=lambda, and rearrange the equation to p=lambda/n
#With that being said, as n approaches infinite numbers, p will becomes closer to zero,
#Lambda will remain constant. In this case, the Binomial and Poisson means are similar
#because when n is large (200), and p is small (0), lambda (lambda = np) is staying constant.
#This is why we are seeing slight overlap between the binomial and poisson distributions.
#The Poisson distribution provides an approximation to the binomail distribution if n is
#large and p is small.