harmonic mean in python

后端 未结 4 1342
臣服心动
臣服心动 2021-01-04 01:23

The Harmonic Mean function in Python (scipy.stats.hmean) requires that the input be positive numbers.

For example:

from scipy import st         


        
4条回答
  •  灰色年华
    2021-01-04 02:18

    You can just use the Harmonic Mean define equation:

    len(a) / np.sum(1.0/a) 
    

    But, wikipedia says that harmonic mean is defined for positive real numbers:

    http://en.wikipedia.org/wiki/Harmonic_mean

提交回复
热议问题