Hi,

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

accuracy.

You can do this e.g. with:

corrcoef(center(a),center(b))

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,

Cheers,

Alois

[1]

https://stats.stackexchange.com/questions/94056/instability-of-one-pass-algorithm-for-correlation-coefficient
On 2018-07-15 02:01, shivax wrote: