harmonicmean: Harmonic Mean

View source: R/utilseq.R

harmonicmeanR Documentation

Harmonic Mean

Description

Calculates the harmonic mean of a numeric vector, robustly handling special cases.

Usage

harmonicmean(x, na.rm = TRUE)
harmonicsum(x, na.rm = TRUE)

Arguments

x

Numeric vector.

na.rm

Logical value specifying whether to remove NA values before processing.

Details

The harmonic mean of a set of numbers is the reciprocal of the mean of the reciprocals of the numbers.

The function harmonicmean calculates the harmonic mean of x. The algorithm robustly handles special cases where some of the values in x are very small or are exactly equal to zero.

The function harmonicsum calculates the reciprocal of the sum of the reciprocals of the x values.

Value

A single numeric value.

Author(s)

\adrian

.

Examples

   harmonicmean(1:3)

spatstat/spatstat.utils documentation built on Oct. 25, 2023, 10:07 p.m.