Function average

Calculates the average of all numbers in an array. Array items which aren't a valid number are ignored and do not factor into averaging.

Use minMaxAvg if you want min, max and total as well.

import * as Numbers from 'https://unpkg.com/ixfx/dist/numbers.js';

// Average of a list
const avg = Numbers.average([1, 1.4, 0.9, 0.1]);

// Average of a variable
const data = [100,200];
Numbers.average(data);

averageWeighted To weight items based on position in array

  • Parameters

    • data: readonly number[]

      Data to average.

    Returns number

    Average of array