Thursday, October 23, 2025
HomeLanguagesUnderstanding Types of Mean | Set 2

Understanding Types of Mean | Set 2

It is one of the most important concepts of statistics, a crucial subject to learn Machine Learning.

  • Geometric Mean: Like arithmetic mean is the sum of all the discrete values in the set, Geometric mean is the product of discrete values in the set. It is useful for the set of positive discrete values. 
     

Example – 

Sequence = {1, 3, 9}

product         = 27
n, Total values = 3
Harmonic Mean   = (27)^(1/3)

Code – 

Python3




# 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)


Output : 

Geometric Mean is : 3
  • Harmonic Mean : Harmonic mean plays it roles when it comes to calculate the mean of the terms which are in defined in relation to any unit. It is the reciprocal of the mean of the reciprocals of the data. It is used where inverse variation in relation is involved in the data. 

 Example – 

Sequence = {1, 3, 9}

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

Code – 

Python3




# 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)


Output : 

Harmonic Mean is : 2.076923076923077
  • Relationship between Arithmetic (AM), Harmonic (HM) and Geometric Mean (GM):
      

Example – 

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
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS