Skip to content

weightedVariance

weightedVariance(x, weights): number

Defined in: src/weighted_variance.js:18

The weighted variance is the average weighted squared deviation from the weighted mean.

This is a population weighted variance: see the variance method for the unweighted population variance.

number[]

population of one or more data points

number[]

non-negative weights for each data point

number

weighted variance

if x is empty, weights is a different length than x, all weights are zero, or a weight is negative

weightedVariance([2, 4, 4, 4, 5, 5, 7, 9], [1, 1, 1, 1, 1, 1, 1, 1]); // => 4