gmean: Function to compute the geometric mean of a numeric vector

View source: R/gmean.r

gmeanR Documentation

Function to compute the geometric mean of a numeric 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. The geometric mean can be used a central position statistics of a random variable.

Usage

gmean(v)

Arguments

v

is a numeric vector

Details

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

Value

This function returns the geometric mean, a numeric scalar.

Author(s)

Christian Salas-Eljatib.

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


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

datana documentation built on June 13, 2025, 1:11 a.m.