# Covariance and Correlation

Covariance and correlation are two very important terms to understand to find relationship between two or more random or feature variables.

**Covariance **is a measure of how changes in one variable are associated with changes in another variable, i.e. it is a measure of how much two variables change together, in a way it indicates the direction of relationship between two variables.

For example :

We may hypothesize as the work experience of a person increases, his income also increases, so to measure how income of a person varies with increase in number of years of work experience, we would calculate covariance

Another example, we may hypothesize that wealthier people are likely to be more educated, so we would try to see how closely measures of wealth and education stay together, we would use a measure of covariance to determine this.

**Correlation:** Correlation is simply a normalized form of covariance.

It is obtained by dividing the covariance of the two variables by the product of their standard deviations.

The values of the correlation coefficient can range from -1 to +1.

The closer it is to +1 or -1, the more closely are the two variables related.

**Implementation:**