Skip to content

sumNthPowerDeviations

sumNthPowerDeviations(x, n): number

Defined in: src/sum_nth_power_deviations.js:18

The sum of deviations to the Nth power. When n=2 it’s the sum of squared deviations. When n=3 it’s the sum of cubed deviations.

number[]

number

power

number

sum of nth power deviations

var input = [1, 2, 3];
// since the variance of a set is the mean squared
// deviations, we can calculate that with sumNthPowerDeviations:
sumNthPowerDeviations(input, 2) / input.length;