Learn R Programming

datana (version 1.0.6)

gmean: Function to compute the geometric mean of a vector

Description

Computes the geometric mean of a numeric vector. It is the n-th root of the product of n numbers, as follows. $$y_g = \left(\prod_{i=1}^{n} y_i\right)^{1/n}$$ for \(y_i > 0\). It can also be understood as the average of the logarithmic values of a data set, converted back to a base 10 number. The geometric mean is a central position statistics of a random variable.

Usage

gmean(v)

Value

This function returns the geometric mean, a numeric scalar.

Arguments

v

is a numeric vector

Author

Christian Salas-Eljatib.

Details

Notice that can only be computed for positive values. For negative values, there are alternatives, but not covered here.

References

Salas-Eljatib, C. 2021. Análisis de datos con el programa estadístico R: una introducción aplicada. Ediciones Universidad Mayor, Santiago, Chile. 170 p. https://eljatib.com/rlibro

Examples

Run this code

y.var <- runif(10, min=10, max=45)
gmean(y.var)

Run the code above in your browser using DataLab