MCPcopy Index your code
hub / github.com/numpy/numpy / var

Method var

numpy/matrixlib/defmatrix.py:486–519  ·  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

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

Callers 1

test_varMethod · 0.45

Calls 1

_collapseMethod · 0.80

Tested by 1

test_varMethod · 0.36