Calculates the sample standard deviation of a specified numeric property in an array of objects. Uses the formula: stdDev = sqrt(variance) with sample variance = Σ((x - mean)²) / (n - 1)
The type of objects in the array.
The array of objects.
The key whose numeric values will be used.
The standard deviation, or NaN if fewer than 2 valid numbers exist.
const data = [{ a: 2 }, { a: 4 }, { a: 4 }, { a: 4 }, { a: 5 }, { a: 5 }, { a: 7 }, { a: 9 }];stdDevBy(data, 'a'); // Returns 2 Copy
const data = [{ a: 2 }, { a: 4 }, { a: 4 }, { a: 4 }, { a: 5 }, { a: 5 }, { a: 7 }, { a: 9 }];stdDevBy(data, 'a'); // Returns 2
Calculates the sample standard deviation of a specified numeric property in an array of objects. Uses the formula: stdDev = sqrt(variance) with sample variance = Σ((x - mean)²) / (n - 1)