Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scipy stats geometric mean returns NaN

I am using scipy's gmean() function to determine the geometric mean of a numpy array that contains voltage outputs. The range of the numbers is between -80.0 and 30.0. Currently, the numpy array is two dimensional, giving the voltage for two different measurements.

array([[-60.0924, -60.0882],
       [-80.    , -80.    ],
       [-80.    , -80.    ],
       ...,
       [-60.9221, -66.0748],
       [-61.0971, -65.9637],
       [-61.2706, -65.8803]])

However, I get NaN when I take the geometric mean:

>>> from scipy import stats as scistats
>>> scistats.gmean(voltages)
array([ NaN,  NaN])

Does anybody have an idea what might be causing this? Am I doing something wrong?

Thanks in advance!

like image 451
Doa Avatar asked Jul 17 '11 19:07

Doa


1 Answers

The geometric mean cannot be applied to negative values.

like image 87
so12311 Avatar answered Nov 08 '22 01:11

so12311