In math, the geometric mean is one of the tree classical Phytohagorean means. The difference is that the geometric mean calcultates the mean using the product (instead of the sum used in the arithmetic mean we all know). The geometric mean is defined as:
\[(\prod_{i=1}^{n} x_i)^{1/n} = \sqrt[n]{x_1*x_2*...*x_n}\]The geometric mean is ofter used for a set of numbers whose values are meant to be multiplied together or are exponential in nature, such as a set of groth figures. For example values of the human population groth or interest rates of a financial investment.
Extra: Geometric vs arithmetic mean
Dit is een langer onderschrift van een afbeelding dat gebruikt zal worden in de lightbox. In this image you can see the geometric visualisation comparing the geometric and the arithmetic mean.
- The perimeter can be calcultated by multiplying the arithmetic mean of the 4 sides and multiply it by 4. This is because the perimeter is calculated by taking the sum of the 4 sides.
- The Area can be calculated by squaring the geometric mean. This is because the area is calculated by taking the square (multiplication) of the sides
In math and programming, we say that we evaluate a function when we replace the argument with a given number. So if we type sqrt(4)
, we evaluate the sqrt
(square root) function. In R, you can evaluate a function inside another function. The evaluations happen from the inside out.
sqrt(15)
round(3.569, digits = 2)
# because the digits argument can not be confused with another argument (it is in the right position)
# this notation can be shortened to:
round(3.569, 2)
round(sqrt(15), 2)
Compute the geometric mean of the Annual Orange growth rates given in the table, round your result to 3 decimals. Do it with one line of code and do not make use of variables.
year | Orange yield | Annual growth rate |
---|---|---|
2017 | 100 | / |
2018 | 160 | 1.6 |
2019 | 192 | 1.2 |
2020 | 96 | 0.5 |
2021 | 240 | 2.5 |
Hint
you can make use of the following rule \(\sqrt[4]{x} = \sqrt[2]{\sqrt[2]{x}}\)