circstat / pycircstat

Toolbox for circular statistics with Python
MIT License
157 stars 42 forks source link

problem with omnibus test with binned data #62

Closed dianamaro closed 5 years ago

dianamaro commented 5 years ago

I don't manage to make the omnibus test with the binned data work. For example, pycircstat.omnibus(np.linspace(0,2*np.pi,8), w = np.array([7,4,1,1,2,1,2,2]))

doesn't work but if I use the rayleigh test instead there is no problem.

fabiansinz commented 5 years ago

Can you send a piece of code that reproduces the error? Can you also send the error message?

dianamaro commented 5 years ago

The code can simply be the one I already posted:

pycircstat.omnibus(np.linspace(0,2*np.pi,8), w = np.array([7,4,1,1,2,1,2,2]))

Which produces the following error:


ValueError Traceback (most recent call last)

in () ----> 1 pycircstat.omnibus(np.linspace(0,2*np.pi,8),w = np.array([7,4,1,1,2,1,2,2])) in omnibus(alpha, w, sz, axis) C:\Users\Student\AppData\Local\conda\conda\envs\neuroanalysis\lib\site-packages\pycircstat-0.0.2-py3.5.egg\pycircstat\decorators.py in _deco(f, *args, **kwargs) 117 118 # compute function --> 119 outputs = f(*args, **kwargs) 120 121 # swap everything back into place C:\Users\Student\AppData\Local\conda\conda\envs\neuroanalysis\lib\site-packages\pycircstat-0.0.2-py3.5.egg\pycircstat\tests.py in omnibus(alpha, w, sz, axis) 121 if np.any(~idx50): 122 pval[~idx50] = 2 ** (1 - n[~idx50]) * (n[~idx50] - \ --> 123 2 * m[~idx50]) * misc.comb(n[~idx50], m[~idx50]) 124 125 return pval.squeeze(), m ValueError: Integers to negative integer powers are not allowed.
fabiansinz commented 5 years ago

As the error message says, numpy as problems with your integer datatypes. You can fix that by

pycircstat.omnibus(np.linspace(0,2*np.pi,8), w = np.array([7,4,1,1,2,1,2,2], dtype=np.float))

or, simply,

pycircstat.omnibus(np.linspace(0,2*np.pi,8), w = np.array([7,4,1,1,2,1,2,2.]))