;+ ; NAME: ; PROBEXP ; ; PURPOSE: ; This function determines the probability function of the ; binned waiting times between successive events from a Poisson source ; in the presence of a non-extended dead time. ; ; CATEGORY: ; Math. ; ; CALLING SEQUENCE: ; ; Result = PROBEXP( Wtmax, Mean, Offset ) ; ; INPUTS: ; Wt: An array of waiting times or the maximum waiting time to ; determine the probability density function at. ; ; Mean: The average waiting time for the source. ; ; Offset: The dead time. ; ; OPTIONAL INPUT KEYWORD PARAMETERS: ; ; BIN: Time resolution of the waiting times, (1=Default). ; ; OUTPUTS: ; This function returns the probabilities at the waiting times ; specified by the Wt parameter if Wt is an array. If Wt is a scalar, ; the waiting times chosen are [0, BIN, 2*BIN, 3*BIN,... N*BIN < Wt]. ; NOTE: To calculate the probability, one must take into account that ; events can fall anywhere within the time resolution, BIN. ; ; EXAMPLE: ; For times binned with a bin time interval of 1, then the possible ; binned waiting times are [0,1,2..] corresponding to REAL waiting ; times of ([0,1], [0,2], [1,3], ...]. If we want to determine the ; probabilities of binned waiting times of [0,10] when the average ; number of counts = 1/bin (without dead time) and the deadtime ; is 2.5, then ; ; avg_cts = 1.0 ; tavg = 1./avg_cts ; dead_time = 2.5 ; max_waiting_time = 10 ; Probs = PROBEXP( max_waiting_time, tavg, dead_time ) ; ; MODIFICATION HISTORY: ; Written by: Han Wen, July 1996. ; 22-AUG-1996 Corrected comments: waiting times not [0,Tmax], but ; [1,Tmax]. ; 23-OCT-1996 Changed arguments from (1/Mean, Offset, Wtmax) to ; (Wtmax, Mean, Offset). First element of output array ; corresponds to waiting time = 0 instead of 1*Bin. ; 06-DEC-1996 Renamed from PROBWT -> PROBEXP ;- function PROBEXP, Wt, Mean, Offset, BIN=Bin ; Check parameters NP = N_PARAMS() if (NP ne 3) then message, $ 'Must be called with 3 parameters: Wt, Mean, Offset' if (N_ELEMENTS(Bin) eq 0) then Bin=1 nWT = N_ELEMENTS(Wt) Wtmax= MAX(Wt) b = DOUBLE(Bin) tau = DOUBLE(Offset) mu = b/Mean nmax = LONG(1.*WTmax/Bin) if (nmax lt 1 ) then message, 'BIN keyword set too large.' if (nWT eq 1) then Prob = DBLARR( nmax+1 ) else Prob = DBLARR( nWT ) if (WTmax lt tau) then return, Prob Kappa= LONG(tau/b) if (nWT gt 1) then begin h1 = WHERE( Wt eq Kappa*b ) h1p1 = WHERE( Wt eq (Kappa+1)*b ) hgt2 = WHERE( Wt gt (Kappa+1)*b ) endif else begin h1 = Kappa h1p1 = Kappa + 1 endelse eps = tau/b - Kappa ; Probability of a binned waiting time of Kappa*Offset if (nmax lt Kappa) then goto, DONE if (h1(0) ne -1) then $ Prob(h1) = 1 - (eps+(1.-EXP(-mu*(1-eps)))/mu) ; Probability of a binned waiting time of (Kappa+1)*Offset if (nmax lt (Kappa+1)) then goto, DONE if (h1p1(0) ne -1) then $ Prob(h1p1)= eps + (1-(2-EXP(-mu))*EXP(-(1-eps)*mu))/mu ; Probability of a binned waiting time > (Kappa+1)*Offset if (nmax lt (Kappa+2)) then goto, DONE if (nWT gt 1) then n = Wt(hgt2)/b $ else begin nbin = nmax - (Kappa+1) n0 = Kappa+2 n =(hgt2 = (LINDGEN(nbin) + n0)) endelse Prob(hgt2) = (4*SINH(mu/2)^2/mu)*EXP(-mu*(n-(eps+Kappa))) DONE: return, Prob end