MCPcopy Index your code
hub / github.com/monkeytypegame/monkeytype / stdDev

Function stdDev

packages/util/src/numbers.ts:44–54  ·  view source on GitHub ↗
(array: number[])

Source from the content-addressed store, hash-verified

42 * @returns The standard deviation of the input array.
43 */
44export function stdDev(array: number[]): number {
45 try {
46 const n = array.length;
47 const meanValue = mean(array);
48 return Math.sqrt(
49 array.map((x) => Math.pow(x - meanValue, 2)).reduce((a, b) => a + b) / n,
50 );
51 } catch (e) {
52 return 0;
53 }
54}
55
56/**
57 * Calculates the median of an array of numbers.

Callers 2

logTimingFunction · 0.90
addResultFunction · 0.90

Calls 1

meanFunction · 0.85

Tested by

no test coverage detected