[SciPy-User] scipy.stats.kendalltau bug?

Nathaniel Smith njs@pobox....
Sun Jul 29 02:47:02 CDT 2012


On Sun, Jul 29, 2012 at 8:27 AM, Jeffrey <zfyuan@mail.ustc.edu.cn> wrote:
> Thanks eat. I found the reason is that numpy.sqrt cannot deal with too large
> number. When calculating kendalltau, assume n=len(x),then the total pair
> number is 'tot' below:
>
>     tot=(n-1)*n//2
>
> when calculating tau, the de-numerator is as below:
>
>     np.sqrt((tot-u)*(tot-v))
>
> u and v stands for ties in x[] and y[perm[]], which is zero if the two array
> sample from continuous dist. Hence (tot-u)*(tot-v) may be out of range for
> the C written ufunc 'np.sqrt', and an Error is then raised.
>
> What about using math.sqrt here, or multiply two np.sqrt in the
> de-numerator? Since big data sets are often seen these days.

It seems like the bug is that np.sqrt is raising an AttributeError on
valid input... can you give an example of a value that np.sqrt fails
on? Like

>>> np.sqrt(<something>)
AttributeError

-n


More information about the SciPy-User mailing list