From the scipy documentation on scipy.stats.kstest, it seems that the function only allows a comparison between a sample and a pre-defined probability distribution. Can it compare between a sample and a self-defined probability distribution?
I could use the two-sample Kolmogorov-Smirnov test, scipy.stats.ks_2samp, to compare a theoretical sample generated from the self-defined function to the actual sample.
I tried the following code:
from scipy.stats import kstest
sample = [1 for i in range(10)]
ks_stat, p_value = kstest(sample, lambda x: 1)
print ks_stat, p_value
>> 1.0, 0.0
The p_value above should give 1 as the sample matches exactly to the distribution.
Links for convenience
One sample KS test: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.kstest.html
Two sample KS test: https://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.stats.ks_2samp.html