;This routine computes the kolmogorov-Smirnov test for the null hypothesis ; that two set of data have the same probability distribution. ; A number close to 0 means the two datasets have different probability distribution ;iplot = 1 means plot the cumulative probability distributions. function kolmo,data1,pdf,nsample,iplot ;nsample = 100 n1 = double(n_elements(data1)) n2 = double(n_elements(pdf)) s1 = dblarr(nsample) x1 = data1 x1 = x1(sort(x1)) xmin = min(x1) xmax = max(x1) x = xmin + dindgen(nsample)*(xmax-xmin)/double(nsample-1) for i=0,nsample-1 do begin if(x(i) ge xmin) then s1(i) = double(n_elements(where(x1 le x(i)))) endfor s1 = s1/n1 s2=pdf if(iplot eq 1) then begin plot,s1 oplot,s2,linestyle=2 endif D = max(abs(s1-s2)) if(D eq 0.0d0) then return,1 N = n1 x = (sqrt(N) + 0.12d0 + 0.11d0/sqrt(N) )*D prob = 0 j=1.0d0 suite: add = (-1.0d0)^(j-1.0d0)*2.0d0*exp(-2.0d0*j^2*x^2) prob = prob + add j = j + 1.0d0 if(abs(add) gt 1.0d-5) then goto,suite return,prob end