FUNCTION TelegraphProcess,t,lambda,p,X0=x0 ;+ ; S=TelegraphProcess(t,lamda,p) ; Generates a random process with X[t]=X[0] if ; the number of zero crossings in (0,t) is even and ; X[t]=-X[0] if the number is odd. The waveform is ; returned in an array of size n=lambda*t/p. If ; p is not specified then the default is p=0.1. The ; probability should be small enough that the Poisson ; assumptions are satisfied. The initial value X[0] can ; be specified with the keyword X0. If it is unspecified, ; it is randomly initialized to +1 or -1. ; ; Harvey Rhody ; March, 2000 ;- IF N_PARAMS() LT 3 THEN p=0.1 n=lambda*t/p u=FIX(RANDOMN(SEED,n,BINOMIAL=[1,p])>0) s=INTARR(n) IF KEYWORD_SET(x0) THEN S[0]=x0 ELSE $ IF RANDOMN(SEED) GE 0 THEN S[0]=1 ELSE S[0]=-1 FOR k=1,n-1 DO s[k]=s[k-1]*(1-2*u[k-1]) RETURN,s END