Function variance

  • Find the sample variance of an array.

    Type Parameters

    • T

    Parameters

    • array: T[]

      An array.

    • Optional iteratee: ((obj) => number)

      The iteratee invoked on each element.

        • (obj): number
        • Parameters

          • obj: T

          Returns number

    Returns number

    Returns the variance.

    Since

    0.1.0

    Example

    variance([1, 2, 3])
    // => 1

    const objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]
    variance(objects, ({ n }) => n)
    // => 6.66666667