Appendix B

function pdevs=poissondev(xm,n) ; %function pdevs=poissondev(xm,n) ;

%Generates n random deviates drawn from a poisson distribution. %Algorithm modified from "Numerical Recipes in C," pp.293-295.

%Modification History:

% BCR 11/25/98 - created first version % BCR 04/02/02 - reformatted for publication pdevs=zeros(1,n); %if xm < 12 0 g=exp(-xm); for i=1:n, j=1;

t=cumprod(rand(1,2*xm)); em=find(t<g); while isempty(em) j=j+1;

t=t(length(t)).*cumprod(rand(2*xm)); em=find(t<g);

0 0

Post a comment