# Understanding Medium Types | Set 2

| | | | | | | | | | | | | | | |

👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!

This is one of the most important concepts in statistics, an essential subject for learning machine learning.

• Geometric mean : As the arithmetic mean is the sum of all discrete values ‚Äã‚Äãin a set, the geometric mean is the product of discrete values ‚Äã‚Äãin a set. This is useful for a set of positive discrete values.

Example —

` Sequence = {1, 3, 9} product = 27 n, Total values ‚Äã‚Äã= 3 Harmonic Mean = (27) ^ (1/3) `

Code —

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

Output:

` Geometric Mean is: 3 `
• Harmonic Mean: Harmonic mean plays a role when it is necessary to calculate the average for terms that are defined in relation to any unit. This is the inverse of the mean of the inverse data. This is used when a reverse change in attitude 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 —

 ` # Harmonic mean ` ` import ` ` numpy as np ` ` # discrete set of numbers ` ` from ` ` scipy.stats.mstats ` ` import ` ` h mean ` ` x ` ` = ` ` h mean ([` ` 1 ` `, ` ` 3 ` `, ` ` 9 ` `]) ` ` # Greedy ` ` 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 `

👻 Read also: what is the best laptop for engineering students?

We hope this article has helped you to resolve the problem. Apart from Understanding Medium Types | Set 2, check other code Python module-related topics.

Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.

By the way, this material is also available in other languages:

Jan Porretti

Singapore | 2023-02-04

Maybe there are another answers? What Understanding Medium Types | Set 2 exactly means?. Checked yesterday, it works!

Javier Jackson

Moscow | 2023-02-04

Maybe there are another answers? What Understanding Medium Types | Set 2 exactly means?. Will use it in my bachelor thesis

Carlo OConnell

Milan | 2023-02-04

I was preparing for my coding interview, thanks for clarifying this - Understanding Medium Types | Set 2 in Python is not the simplest one. Will use it in my bachelor thesis

## Shop Learn programming in R: courses

\$FREE Best Python online courses for 2022

\$FREE Best laptop for Fortnite

\$399+ Best laptop for Excel

\$ Best laptop for Solidworks

\$399+ Best laptop for Roblox

\$399+ Best computer for crypto mining

\$499+ Best laptop for Sims 4

\$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

PythonStackOverflow

Check if one list is a subset of another in Python

PythonStackOverflow

How to specify multiple return types using type-hints

PythonStackOverflow

Printing words vertically in Python

PythonStackOverflow

Python Extract words from a given string

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

PythonStackOverflow

Python os.path.join () method

PythonStackOverflow

Flake8: Ignore specific warning for entire file

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries