harmonic mean in python

后端 未结 4 1303
臣服心动
臣服心动 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:19

    The harmonic mean is only defined for sets of positive real numbers. If you try and compute it for sets with negatives you get all kinds of strange and useless results even if you don't hit div by 0. For example, applying the formula to the set (3, -3, 4) gives a mean of 12!

提交回复
热议问题