UNPKG

2.31 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function std
4
5Compute the standard deviation of a matrix or a list with values.
6The standard deviations is defined as the square root of the variance:
7`std(A) = sqrt(variance(A))`.
8In case of a (multi dimensional) array or matrix, the standard deviation
9over all elements will be calculated by default, unless an axis is specified
10in which case the standard deviation will be computed along that axis.
11
12Additionally, it is possible to compute the standard deviation along the rows
13or columns of a matrix by specifying the dimension as the second argument.
14
15Optionally, the type of normalization can be specified as the final
16parameter. The parameter `normalization` can be one of the following values:
17
18- 'unbiased' (default) The sum of squared errors is divided by (n - 1)
19- 'uncorrected' The sum of squared errors is divided by n
20- 'biased' The sum of squared errors is divided by (n + 1)
21
22
23## Syntax
24
25```js
26math.std(a, b, c, ...)
27math.std(A)
28math.std(A, normalization)
29math.std(A, dimension)
30math.std(A, dimension, normalization)
31```
32
33### Parameters
34
35Parameter | Type | Description
36--------- | ---- | -----------
37`array` | Array &#124; Matrix | A single matrix or or multiple scalar values
38`normalization` | string | Determines how to normalize the variance. Choose 'unbiased' (default), 'uncorrected', or 'biased'. Default value: 'unbiased'.
39
40### Returns
41
42Type | Description
43---- | -----------
44* | The standard deviation
45
46
47## Examples
48
49```js
50math.std(2, 4, 6) // returns 2
51math.std([2, 4, 6, 8]) // returns 2.581988897471611
52math.std([2, 4, 6, 8], 'uncorrected') // returns 2.23606797749979
53math.std([2, 4, 6, 8], 'biased') // returns 2
54
55math.std([[1, 2, 3], [4, 5, 6]]) // returns 1.8708286933869707
56math.std([[1, 2, 3], [4, 6, 8]], 0) // returns [2.1213203435596424, 2.8284271247461903, 3.5355339059327378]
57math.std([[1, 2, 3], [4, 6, 8]], 1) // returns [1, 2]
58math.std([[1, 2, 3], [4, 6, 8]], 1, 'biased') // returns [0.7071067811865476, 1.4142135623730951]
59```
60
61
62## See also
63
64[mean](mean.md),
65[median](median.md),
66[max](max.md),
67[min](min.md),
68[prod](prod.md),
69[sum](sum.md),
70[variance](variance.md)