numpy.matrix.std

方法

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

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

参照 numpy.std 完整文件。

参见

numpy.std

笔记

这和 ndarray.std 但如果 ndarray 将被退回,A 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]])