This recipe explains what is covariance and how to find covariance in python
What is covariance? How to find covariance in python? Covariance It is the measure of the strength of correlation between two variables or set of variables. There are certain possibilities which are:
Cov(xi, xj) = 0 then the variabels are not correlated
Cov(xi, xj) > 0 then the variabels are possitively correlated
Cov(xi, xj) >< 0 then the variabels are negatively correlated.
import numpy as np
Sample_data = np.array([[11,20,35],[40,58,64],[71,87,96]])
print("This is Sample array:","\n",Sample_data)
This is Sample array: [[11 20 35] [40 58 64] [71 87 96]]
print("The Covariance of Sample data:","\n",np.cov(Sample_data))
The Covariance of Sample data: [[147. 138. 146.5 ] [138. 156. 157. ] [146.5 157. 160.33333333]]