geometricMean

Calculates the geometric mean for a non-empty array of finite positive values.

import { Arith } from "@teakit/arith";

Arith.geometricMean(["1", "4"]).toString(); // "2"
Arith.geometricMean(["1", "8", "27"]).toString(); // "6"

const Short = Arith.clone({ DECIMAL_PLACES: 4 });
Short.geometricMean(["2", "3"]).toString(); // "2.4495"

API Reference

Signature

Arith.geometricMean(values: readonly ArithValue[]): ArithInstance;

Parameters

ParameterTypeRequiredNotes
valuesreadonly ArithValue[]YesNon-empty array of finite positive values.

Returns

Returns the nth root of the product of all values.

Throws

  • Throws if values is not a non-empty array.
  • Throws if any value is 0, negative, NaN, Infinity, or -Infinity.

Agent Contract

FieldValue
Kindstatic method
Canonical namegeometricMean
AliasesNone
Mutates receiverNo
ReturnsArithInstance
Accepts (string, base) overloadNo
Configuration dependenciesDECIMAL_PLACES, ROUNDING_MODE, STRICT
Related methodsmean, pow

Agent Notes

  • Use only for positive values.
  • Use mean for arithmetic mean.