# epage 74 # # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- Nsim = 10^3; # Part (a): The code for the Poisson RV generator: # lambda = 100 spread = 4*sqrt(lambda) t = round( seq( max(0,lambda-spread),lambda+spread,1 ) ) prob = ppois(t,lambda) X = rep(0,Nsim) for( i in 1:Nsim ){ u = runif(1) X[i] = t[1] + sum(prob