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.
Parameters
Section titled “Parameters”number[]
population of one or more data points
weights
Section titled “weights”number[]
non-negative weights for each data point
Returns
Section titled “Returns”number
weighted variance
Throws
Section titled “Throws”if x is empty, weights is a different length than x, all weights are zero, or a weight is negative
Example
Section titled “Example”weightedVariance([2, 4, 4, 4, 5, 5, 7, 9], [1, 1, 1, 1, 1, 1, 1, 1]); // => 4