# Poisson Random generator
### Compare the time it takes for the two algorithms in 5000
simulations of
#  a Poisson random variable with parameter λ =
10,200,500.
poisn.gen=function(lambda,size){
x=NULL
for (j in 1:size) {
   u=runif(1)
   p=exp(-lambda)
   f=p
   i=0
   s=0
   while(s==0){
     if(u
       x=append(x,i,after =
length(x))
       s=1
     }
     else{
       p=(p*lambda)/(i+1)
       f=f+p
       i=i+1
     }
   }
}
return(x)
}
poisn.gen(10,5000)
poisn.gen(200,5000)
poisn.gen(500,5000)
hist(poisn.gen(500,5000))