FUNCTION PoissonProcess,t,lambda,p ;+ ; S=PoissonProcess(t,lambda,p) ; divides the interval [0,t] into intervals of size ; deltaT=p/lambda where p is sufficiently small so that ; the Poisson assumptions are satisfied. The value of ; p may be specified by the third positional variable. ; If it is not provided, it is set to the default value ; p=0.1. ; ; The interval (0,t) is divided into n=t*lambda/p intervals ; and the number of events in the interval (0,k*deltaT) is ; returned in the array S. The maximum length of S is 10000. ; ; USAGE ; S=PoissonProcess(10,1,0.1) ; Plot,S ; FOR m=1,10 DO OPLOT,PoissonProcess(10,1,0.1) ; ; The above generate a number of overlayed plots of the process. ; ; Harvey Rhody ; March, 2000 ;- NP=N_PARAMS() IF NP LT 3 THEN p=0.1 n=lambda*t/p ;u=FIX(RANDOMN(SEED,n,BINOMIAL=[1,p])>0) u=Randomn(seed,n,Poisson=p) s=INTARR(n+1) FOR k=1,n DO s[k]=s[k-1]+u[k-1] RETURN,s END