Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

covariance in python

# Covariance provides the a measure of strength of correlation between two variable or more set of variables. The covariance matrix element Cij is the covariance of xi and xj. The element Cii is the variance of xi. 

# If COV(xi, xj) = 0 then variables are uncorrelated
# If COV(xi, xj) > 0 then variables positively correlated
# If COV(xi, xj) > < 0 then variables negatively correlated


# Python code to demonstrate the use of numpy.cov
import numpy as np
 
x = np.array([[0, 3, 4], [1, 2, 4], [3, 4, 5]])
 
print("Shape of array:
", np.shape(x))
 
print("Covariance matrix of x:
", np.cov(x))
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #covariance #python
ADD COMMENT
Topic
Name
1+3 =