acidbase.geometric_mean

acidbase.geometric_mean(x: ndarray, *, remove_na: bool = True, zero_propagate: bool = False) float

Compute the geometric mean.

Parameters:
  • x (array-like) – Numeric vector.

  • remove_na (bool) – If True (default), NA/NaN values are removed before computing.

  • zero_propagate (bool) – If True, return 0 when any element is zero. If False (default), zeros are excluded before computing, but the full length of x (including zeros) is used as the denominator — matching R’s geometricMean default.

Returns:

Geometric mean of x.

Return type:

float

Notes

Returns NaN when any element is negative (R semantics).