You are viewing an older version (2.4.3).Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / matrixlib / defmatrix / matrix / var

function

numpy.matrixlib.defmatrix:matrix.var

source: /numpy/matrixlib/defmatrix.py:488

Signature

def var(self, axis = None, dtype = None, out = None, ddof = 0)

Summary

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

Extended Summary

Refer to numpy.var for full documentation.

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()
x.var(0)
✗
matrix([[10.6667, 10.6667, 10.6667, 10.6667]])
x.var(1)
✓
matrix([[1.25],
        [1.25],
        [1.25]])

See also

numpy.var

Aliases

  • numpy.matrix.var