Harmonic mean, for a set of observations is the number of observations divided by the sum of the reciprocals of the values and it cannot be defined if some of the values are zero.
This blog is in continuation with STATISTICAL APPLICATION IN R & PYTHON: CHAPTER 1 – MEASURE OF CENTRAL TENDENCY. However, here we will discover Harmonic mean and its application using Python and R.
Table for the problem:
So, the average rate of the milk in rupees/liter is 12.95349 = 13 Rs/liter (Approx)
We get this answer from the Harmonic Mean, calculated in R.
First, make a data frame of the available data in Python.
Now, calculate the Harmonic mean from the following data frame.
So, the average rate of the milk in rupees/liter is 12.953491609077956 = 13 Rs/Liter (Approx)
We get this answer from Harmonic mean, calculated in Python.
In this data, we have a few large values which are putting an effect on the average value, if we calculate the average in Arithmetic mean, but in Harmonic mean, we get a perfect average from the data, and also for calculating the average rate.
Use of Harmonic mean is very limited. Harmonic mean gives the largest value to the smallest item and smallest value to the largest item.
Where there are a few extremely large or small values, Harmonic mean is preferable to Arithmetic mean as an average.
The Harmonic mean is mainly useful in averages involving time, rate & price.
Note – If you want to learn the calculation of Geometric Mean, you can check our post on CALCULATING GEOMETRIC MEAN USING R AND PYTHON.
Interested in a career in Data Analyst?
To learn more about Machine Learning Using Python and Spark – Enrol Now.
To learn more about Data Analyst with SAS Course – Enrol Now.
To learn more about Data Analyst with Apache Spark Course – Enrol Now.
To learn more about Data Analyst with Market Risk Analytics and Modelling Course – Enrol Now.
Machine Learning Certification, Machine Learning course, Machine Learning course in Gurgaon, Machine Learning Courses, Machine Learning Training, Machine Learning Using Python, Python, Python certification, python certification course, Python courses, python data science course, Python Training Institute, Software tools : SAS, R, Python etc