Python | Numpy matrix.var ()



Using the Numpy matrix.var () method, we can find the variance of a matrix using matrix.var () .

Syntax: matrix.var ()
Return: Return variance of a matrix

Example # 1:
In this example we can see that using matrix.var () we can find the variance of a given matrix.

# import important module into python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[4, 1; 12, 3]` )

  
# using the matrix.var () method

geek = gfg.var ()

 

print (geek)

Exit:

 17.5 

Example # 2:

# import important module in python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[4, 1, 9; 12, 3, 1; 4, 5, 6] ` )

  
# using the matrix.var () method

geek = gfg.var ()

 

print (geek)

Exit :

 11.5555555556