Compute the weighted arithmetic mean of an array.
Numeric.stat.average(values, weights, level)Averages the values with the supplied weights.
- Parameters:
values: Vector or matrix of input valuesweights: Weights applied to each valuelevel: Optional axis along which to average
- Returns: Weighted mean of the values
- NumPy: Equivalent to
np.average.
import Numeric from '@neabyte/numerix'
const value = Numeric.stat.average([1, 2, 3])
console.log(value)
// 2import Numeric from '@neabyte/numerix'
const value = Numeric.stat.average([1, 2, 3], [1, 1, 2])
console.log(value)
// 2.25import Numeric from '@neabyte/numerix'
const value = Numeric.stat.average([1, 2, 3], [1, 1, 1])
console.log(value)
// 2import Numeric from '@neabyte/numerix'
const value = Numeric.stat.average([0, 10], [1, 3])
console.log(value)
// 7.5