📜  了解平均值的类型 |设置 2

📅  最后修改于: 2022-05-13 01:55:09.314000             🧑  作者: Mango

了解平均值的类型 |设置 2

它是统计学中最重要的概念之一,是学习机器学习的关键学科。

  • 几何平均值:算术平均值是集合中所有离散值的总和,几何平均值是集合中离散值的乘积。它对于一组正离散值很有用。

    例子 -
    Sequence = {1, 3, 9}
    
    product         = 27
    n, Total values = 3
    Harmonic Mean   = (27)^(1/3)
    

    代码 -

    # Geometric Mean 
      
    import numpy as np
      
    # discrete set of numbers
    from scipy.stats.mstats import gmean
    x = gmean([1, 3, 9])
      
    # Mean 
    print("Geometric Mean is :", x) 
    

    输出 :

    Geometric Mean is : 3
  • 谐波平均值:在计算与任何单位相关的术语的平均值时,谐波平均值起着重要作用。它是数据倒数的平均值的倒数。它用于数据中涉及反向变化的情况。

    例子 -

    Sequence = {1, 3, 9}
    
    sum of reciprocals = 1/1 + 1/3 + 1/9
    n, Total values    = 3
    Harmonic Mean      = 3 / (sum of reciprocals)
    

    代码 -

    # Harmonic Mean 
      
    import numpy as np
      
    # discrete set of numbers
    from scipy.stats.mstats import hmean
    x = hmean([1, 3, 9])
      
    # Mean 
    print("Harmonic Mean is :", x) 
    

    输出 :

    Harmonic Mean is : 2.076923076923077
  • 算术 (AM)、谐波 (HM) 和几何平均值 (GM) 之间的关系:

    例子 -
    Sequence = {1, 3, 9}
    
    sum of reciprocals = 1/1 + 1/3 + 1/9
    Sum                = 10
    Product            = 27
    n, Total values    = 3
    
    Arithmetic Mean = 4.33
    Geometric Mean  = 3 
    Harmonic Mean   = 3 / (sum of reciprocals) = 2.077