Reputation: 21
I want to perform the KS-test on my data by comparing it to a uniform distribution that has been scaled.
How do I pass just a scale parameter to the args in scipy.stats.kstest (without passing any other argument to it)? I want it to take the default value for the other arguments (egs:loc)
See:
1. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.uniform.html
2. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.kstest.html
I tried the following but it did not work (invalid syntax)
stats.kstest(data, 'uniform',args=(scale=15.0))
Upvotes: 2
Views: 406
Reputation: 32878
In this case, create a lambda for the distribution you want and divide the x parameter by the desired scale. An example follows:
import random
import scipy.stats as stats
data=[random.random()*15 for i in range(10000)]
stats.kstest(data, lambda x: stats.uniform.cdf(x/15.0))
An alternative approach, which works for the distributions found in SciPy:
stats.kstest(data, lambda x: stats.uniform.cdf(x,scale=15.0))
Upvotes: 1