matrix.var()

numpy.matrix.var

matrix.var(axis=None, dtype=None, out=None, ddof=0) [source]

Returns the variance of the matrix elements, along the given axis.

Refer to numpy.var for full documentation.

See also

numpy.var

Notes

This is the same as ndarray.var, except that where an ndarray would be returned, a matrix object is returned instead.

Examples

>>> x = np.matrix(np.arange(12).reshape((3, 4)))
>>> x
matrix([[ 0,  1,  2,  3],
        [ 4,  5,  6,  7],
        [ 8,  9, 10, 11]])
>>> x.var()
11.916666666666666
>>> x.var(0)
matrix([[ 10.66666667,  10.66666667,  10.66666667,  10.66666667]])
>>> x.var(1)
matrix([[ 1.25],
        [ 1.25],
        [ 1.25]])

© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matrix.var.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部