Von Mises distribution for Kuiper test

Hello all,
I want to use Kuiper test to see whether my distribution is Von Mises distribution or not. The problem is that I cannot find out how should I defined cdf in the kuiper test. The documentation mentions this:

astropy.stats.kuiper(data, cdf=<function <lambda>>, args=())

How should I define the function of CDF for Von Mises distribution?
I have already found a scipy command that can estimate the cdf of Von Mises distribution. This is discussed here. However, I am not sure how to use it in the Kuiper test.

I use the following command for instance:

astropy.stats.kuiper(a,vonmises.cdf(a, 137.2221, loc=-0.7414, scale=1))

However I get the following error:


  File "<ipython-input-11-cee05f94c313>", line 1, in <module>
    astropy.stats.kuiper(a,vonmises.cdf(a, 137.2221, loc=-0.7414, scale=1))

  File "C:\Python\Anaconda3\lib\site-packages\astropy\stats\funcs.py", line 1386, in kuiper
    cdfv = cdf(data, *args)

TypeError: 'numpy.ndarray' object is not callable```
1 Like

The Kuiper function takes a callable (a function) for the CDF argument. In your example above you pass the evaluated function. There are two good ways to fix this: 1) to “freeze” the distribution and 2) to pass the arguments to the unfrozen distribution using kuiper's args=.

First I need to import stuff and make a fake data set

from astropy.stats import kuiper
from scipy.stats import vonmises

import numpy as np
data = np.linspace(0, 1)

This is method (1), the frozen distribution. It’s nice because frozenvm can be used anywhere and we can use keyword arguments instead of positional arguments.

frozenvm = vonmises(kappa=137.2221, loc=-0.7414, scale=1)
kuiper(data, frozenvm.cdf)

This is method (2), passing the arguments. It works in a pinch, but I prefer method (1)

kuiper(data, vonmises.cdf, args=(137.2221, -0.7414, 1))

Thanks for your response @nstarman. One more question: what is the default significance level in the Kuiper test of astropy? is it 5%? I could not find it in the documentation.

@bradley , I think this question is for you :slight_smile:

@A-ep93, I think you are looking to understand kuiper_false_positive_probability, which is the fpp (second) output of kuiper

Actually, I don’t have any experience or expertise with the Kuiper test. It looks like it was added by Anne Archibald in Implemented Kuiper test and some support functions by aarchiba · Pull Request #3724 · astropy/astropy · GitHub</tit