函数 std #

计算矩阵或数值列表的标准差。标准差定义为方差的平方根:std(A) = sqrt(variance(A))。对于(多维)数组或矩阵,默认情况下将计算所有元素的标准差,除非指定了轴,在这种情况下将沿该轴计算标准差。

此外,还可以通过指定维度作为第二个参数来计算矩阵沿行或列的标准差。

可选地,可以将归一化类型指定为最后一个参数。参数normalization可以是以下值之一:

Syntax #

math.std(a, b, c, ...)
math.std(A)
math.std(A, normalization)
math.std(A, dimension)
math.std(A, dimension, normalization)

Parameters #

Parameter Type Description
array Array | Matrix 单个矩阵或多个标量值
normalization string 确定如何对\u65b9\u5dee\u8fdb\u884c\u5f52\u4e00\u5316\u3002\u9009\u62e9 ‘unbiased’(\u9ed8\u8ba4\u503c)、‘uncorrected’ 或 ‘biased’。\u9ed8\u8ba4\u503c: ‘unbiased’。

Returns #

Type Description
* 标准差

Throws #

Type | Description —- | ———–

Examples #

math.std(2, 4, 6)                     // returns 2
math.std([2, 4, 6, 8])                // returns 2.581988897471611
math.std([2, 4, 6, 8], 'uncorrected') // returns 2.23606797749979
math.std([2, 4, 6, 8], 'biased')      // returns 2

math.std([[1, 2, 3], [4, 5, 6]])      // returns 1.8708286933869707
math.std([[1, 2, 3], [4, 6, 8]], 0)    // returns [2.1213203435596424, 2.8284271247461903, 3.5355339059327378]
math.std([[1, 2, 3], [4, 6, 8]], 1)    // returns [1, 2]
math.std([[1, 2, 3], [4, 6, 8]], 1, 'biased') // returns [0.7071067811865476, 1.4142135623730951]

另请参阅 #

mean, median, max, min, prod, sum, variance

Fork me on GitHub