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
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.