std
Calculates the standard deviation of an array of numbers.
Syntax
typescript
std(numbers: number[]): numberParameters
| Name | Type | Description |
|---|---|---|
numbers | number[] | Array of numbers to calculate std. |
Return
| Type | Description |
|---|---|
number | The standard deviation of the values. |
Example
typescript
std([2, 4, 4, 4, 5, 5, 7, 9]); // 2
std([1, 2, 3, 4, 5]); // 1.4142135623730951Notes
- Throws
TypeErrorif the argument is not an array of numbers. - Returns
NaNfor an empty array. - Uses the sample standard deviation formula.
