@jonahsnider/util

    Function mean

    • Get the arithmetic 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 mean of the array

      Math

      const array = [1, 2, 3];

      mean(array); // 2
      • (median:1) to calculate the median of an array
      • mode to calculate the mode of an array
      • geometricMean to calculate the geometric mean of an array
      • harmonicMean to calculate the harmonic mean of an array
    • Get the arithmetic mean of an array of bigints.

      Time complexity: O(n)

      Space complexity: O(1)

      Parameters

      • array: readonly bigint[]

        The array to calculate the mean of

      Returns bigint

      The mean of the array

      Math

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

      mean(array); // 2n
      • (median:2) to calculate the median of an array
      • mode to calculate the mode of an array
    MMNEPVFCICPMFPCPTTAAATR