MCPcopy Create free account
hub / github.com/numpy/numpy / var

Method var

numpy/matrixlib/defmatrix.py:482–514  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

480 return N.ndarray.std(self, axis, dtype, out, ddof, keepdims=True)._collapse(axis)
481
482 def var(self, axis=None, dtype=None, out=None, ddof=0):
483 """
484 Returns the variance of the matrix elements, along the given axis.
485
486 Refer to `numpy.var` for full documentation.
487
488 See Also
489 --------
490 numpy.var
491
492 Notes
493 -----
494 This is the same as `ndarray.var`, except that where an `ndarray` would
495 be returned, a `matrix` object is returned instead.
496
497 Examples
498 --------
499 >>> x = np.matrix(np.arange(12).reshape((3, 4)))
500 >>> x
501 matrix([[ 0, 1, 2, 3],
502 [ 4, 5, 6, 7],
503 [ 8, 9, 10, 11]])
504 >>> x.var()
505 11.916666666666666
506 >>> x.var(0)
507 matrix([[ 10.66666667, 10.66666667, 10.66666667, 10.66666667]]) # may vary
508 >>> x.var(1)
509 matrix([[1.25],
510 [1.25],
511 [1.25]])
512
513 """
514 return N.ndarray.var(self, axis, dtype, out, ddof, keepdims=True)._collapse(axis)
515
516 def prod(self, axis=None, dtype=None, out=None):
517 """

Callers 1

test_varMethod · 0.45

Calls 1

_collapseMethod · 0.80

Tested by 1

test_varMethod · 0.36