harmonic mean in python

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

    There is a statistics library if you are using Python >= 3.6:

    https://docs.python.org/3/library/statistics.html

    You may use its mean method like this. Let's say you have a list of numbers of which you want to find mean:

    list = [11, 13, 12, 15, 17]
    import statistics as s
    s.harmonic_mean(list)
    

    It has other methods too like stdev, variance, mode, mean, median etc which too are useful.

提交回复
热议问题