std.md (2361B)
1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> 2 3 # Function std 4 5 Compute the standard deviation of a matrix or a list with values. 6 The standard deviations is defined as the square root of the variance: 7 `std(A) = sqrt(variance(A))`. 8 In case of a (multi dimensional) array or matrix, the standard deviation 9 over all elements will be calculated by default, unless an axis is specified 10 in which case the standard deviation will be computed along that axis. 11 12 Additionally, it is possible to compute the standard deviation along the rows 13 or columns of a matrix by specifying the dimension as the second argument. 14 15 Optionally, the type of normalization can be specified as the final 16 parameter. 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 26 math.std(a, b, c, ...) 27 math.std(A) 28 math.std(A, normalization) 29 math.std(A, dimension) 30 math.std(A, dimension, normalization) 31 ``` 32 33 ### Parameters 34 35 Parameter | Type | Description 36 --------- | ---- | ----------- 37 `array` | Array | 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 42 Type | Description 43 ---- | ----------- 44 * | The standard deviation 45 46 47 ### Throws 48 49 Type | Description 50 ---- | ----------- 51 52 53 ## Examples 54 55 ```js 56 math.std(2, 4, 6) // returns 2 57 math.std([2, 4, 6, 8]) // returns 2.581988897471611 58 math.std([2, 4, 6, 8], 'uncorrected') // returns 2.23606797749979 59 math.std([2, 4, 6, 8], 'biased') // returns 2 60 61 math.std([[1, 2, 3], [4, 5, 6]]) // returns 1.8708286933869707 62 math.std([[1, 2, 3], [4, 6, 8]], 0) // returns [2.1213203435596424, 2.8284271247461903, 3.5355339059327378] 63 math.std([[1, 2, 3], [4, 6, 8]], 1) // returns [1, 2] 64 math.std([[1, 2, 3], [4, 6, 8]], 1, 'biased') // returns [0.7071067811865476, 1.4142135623730951] 65 ``` 66 67 68 ## See also 69 70 [mean](mean.md), 71 [median](median.md), 72 [max](max.md), 73 [min](min.md), 74 [prod](prod.md), 75 [sum](sum.md), 76 [variance](variance.md)