I would like to run some tests for the null hypothesis that the times of events I have was created from a homogeneous Poisson process (see e.g. http://en.wikipedia.org/wiki/Poisson_process ). For a fixed number of events the times should therefore look like a sorted version of a uniform distribution in the appropriate range. There is an implementation of the Kolmogorov-Smirnov test at http://docs.scipy.org/doc/scipy-0.7.x/reference/generated/scipy.stats.kstest.html but I can't see how to use it here as scipy.stats doesn't seem to know about Poisson processes.
As a simple example, this sample data should give a high p-value for any such test.
import random
nopoints = 100
max = 1000
points = sorted([random.randint(0,max) for j in xrange(nopoints)])
How can I make a sensible test for this problem?
From www.stat.wmich.edu/wang/667/classnotes/pp/pp.pdf I see
" REMARK 6.3 ( TESTING POISSON ) The above theorem may also be used to test the hypothesis that a given counting process is a Poisson process. This may be done by observing the process for a fixed time t. If in this time period we observed n occurrences and if the process is Poisson, then the unordered occurrence times would be independently and uniformly distributed on (0, t]. Hence, we may test if the process is Poisson by testing the hypothesis that the n occurrence times come from a uniform (0, t] population. This may be done by standard statistical procedures such as the Kolmogorov-Smirov test."
>>> import scipy.stats as stats >>> stats.poisson.pmf(1, mu=3) 0.14936120510359185
kstest
assume that it's a continuous distribution with no estimated parameters, and the p-values will not be correct if that's not the case in your problem. (applies also to Hooked's answer)kstest
with the uniform as Null distribution. If you have discrete events or event times, then you can use the chisquare distribution. There was just the same question on the statsmodels mailing list with other tests for homogeneity of a Poisson process (for example with binning into time intervals), but I don't have any ready to use tests for this.