Learn R Programming

datana (version 1.0.9)

hmean: Function to compute the harmonic mean of a numeric vector

Description

Computes the harmonic mean of a numeric vector. It is the inverse of the mean of the recriprocals of n numbers, as follows. $$y_h = \frac{n}{\left(\sum_{i=1}^{n} \frac{1}{y_i}\right)}$$ for \(y_i \neq 0\). The harmonic mean can be used a central position statistics of a random variable.

Usage

hmean(v)

Value

This function returns the harmonic mean, a numeric scalar.

Arguments

v

is a numeric vector

Author

Christian Salas-Eljatib.

Details

Notice that can only be computed for values different from cero.

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)
hmean(y.var)

Run the code above in your browser using DataLab