[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correlation with nan package

From: Alois Schlögl
Subject: Re: Correlation with nan package
Date: Sun, 15 Jul 2018 21:26:54 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1


currently, corrcoef from the nan-toolbox uses the faster one-pass 
algorithm, that is known to have reduced accuracy.
It's an issue when the data has a very low coefficient of variation
(i.e. std(x)/mean(x) is in the order of sqrt(eps) ) . (for details see
also [1]).

There is a simple workaround, just remove the mean before doing corrcoef.
It will produce the same correlation, and is not subject to the limited
You can do this e.g. with:

This approach corresponds to the more accurate two-pass algorithm.
Eventually, I might implement the more accurate two-pass algorithm.
Because it has some implications in terms of speed and memory
requirement, users might want to control whether one or the other
algorithm is used.

I hope this answers your questions,




On 2018-07-15 02:01, shivax wrote:
> hi all,
> i'm using this package
> i use corrcoef(a,b)
> but sometimes i see this return: Inf (infinite)
> how it is possible to return Inf if correlation varies from a minimum of 1
> to -1?
> --
> Sent from:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]