numpy.matrix.std#

方法

matrix.std(axis=None, dtype=None, out=None, ddof=0)[源代码]#

返回给定轴上数组元素的标准差。

请参考 numpy.std 获取完整文档。

另请参阅

numpy.std

注意

这与 ndarray.std 相同,不同之处在于,当 ndarray 将被返回时,matrix 对象会被返回。

示例

>>> x = np.matrix(np.arange(12).reshape((3, 4)))
>>> x
matrix([[ 0,  1,  2,  3],
        [ 4,  5,  6,  7],
        [ 8,  9, 10, 11]])
>>> x.std()
3.4520525295346629 # may vary
>>> x.std(0)
matrix([[ 3.26598632,  3.26598632,  3.26598632,  3.26598632]]) # may vary
>>> x.std(1)
matrix([[ 1.11803399],
        [ 1.11803399],
        [ 1.11803399]])