Function geometricMean

  • Get the geometric mean of an array of numbers.

    Time complexity: O(n)

    Space complexity: O(1)

    Parameters

    • array: readonly number[]

      The array to calculate the mean of

    Returns number

    The geometric mean of the array

    Math

    const array = [1, 2, 3, 4];

    geometricMean(array); // 24 ** (1 / 4)
    • (mean:1) to calculate the arithmetic mean of an array
    • geometricMean to calculate the harmonic mean of an array