[SciPy-User] np.corrcoef ddof is redundant?

Matthew Brett matthew.brett at gmail.com
Tue Mar 10 16:12:25 EDT 2015


Hi,

On Tue, Mar 10, 2015 at 9:27 AM, Sturla Molden <sturla.molden at gmail.com> wrote:
> Alistair Miles <alimanfoo at googlemail.com> wrote:
>
>> I'm trying to calculate correlation coefficients and looking at the
>> np.corrcoef function. It has bias and ddof arguments, however when I try
>> different values of ddof with test data the results are always the same,
>> i.e., changing ddof has no effect. From some back-of-the-envelope algebra I
>> reckon the n/(n-ddof) normalisations should get cancelled out when
>> calculating correlation coefficients from a covariance matrix, and
>> therefore the ddof (and bias) arguments to np.corrcoef are redundant.
>>
>> I'd be very grateful if someone could verify this is true or tell me if
>> I've missed something.
>
> You are right. It should cancel out or np.corrcoef would be wrong. The
> sample size does not go into the Pearson product-moment correlation.

Oh dear - that's embarrassing.

https://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient

I guess we should deprecate the 'bias' and 'ddof' input arguments asap.

Cheers,

Matthew



More information about the SciPy-User mailing list