Sample variance formula is:
Variance formula is:
To calculate sample variance of a matrix, you can compute variance first.
Preliminaries
import numpy as np
Create a matrix
m = np.array([[2, 3, 5],[1, 4, 6]])
The result is:
array([[2, 3, 5], [1, 4, 6]])
Compute variance of matrix
v = np.var(m)
The result is:
2.9166666666666665
Compute sample variance
sv = v * (m.size/((m.size - 1)*1.0))
The result is:
3.4999999999999996