[SciPy-User] scipy.stats.pearsonr returns exactly 0.0
Andreas Hilboll
lists at hilboll.de
Mon Feb 4 11:30:00 EST 2013
>> Hi,
>>
>> in a situation where scipy.stats.spearmanr and numpy.corrcoef[0,1]
>> return sensible results, scipy.stats.pearsonr returns exactly 0.0.
>>
>> Are there situations where this is to be expected? I have sanitized my
>> input arrays for nans before calling the correlation methods:
>>
>> tmpdata1 = data[key1].data[:, x, y]
>> tmpdata2 = data[key2].data[:, x, y]
>> tmpidx = True - (np.isnan(tmpdata1) | np.isnan(tmpdata2))
>> tmpdata1, tmpdata2 = tmpdata1[tmpidx], tmpdata2[tmpidx]
>>
>> The results I get is:
>>
>> sp.stats.linregress: 0.09.../.....
>> sp.stats.spearmanr: 0.331...
>> np.corrcoef: 0.2574...
>> sp.stats.pearsonr: 0.0 (exactly)
>>
>> I'm a bit worried that pearsonr is exactly 0.00. Any ideas?
>>
>
>
> Can you provide your data?
>
> Warren
Problem solved. For some reason (which I don't understand) warnings were
suppressed in my script. After extracting the data and running pearsonr
in an ipython shell, I got a RuntimeWarning("overflow encountered in
float_scalars"). My tmpdata arrays were float32. After changing them to
float64, I a pearsonr of 0.30694, which seems reasonable.
Sorry for the noise.
Andreas.
More information about the SciPy-User
mailing list