# Correlation and Covariance

### Correlation

* **Positive** correlation exists when larger values of $$x$$ correspond to larger values of $$y$$ and vice versa.
* **Negative** correlation exists when larger values of $$x$$ correspond to smaller values of $$y$$ and vice versa.
* **Weak or no** correlation exists if there is no such apparent relationship.

![](https://2552912007-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LzGBVuquaFNrwdmJna0%2F-LzJ0r3HfKSd3m6i1vAJ%2F-LzJ1aO1MvuWkMQuh6XJ%2FScreen%20Shot%202020-01-23%20at%201.13.59%20PM.png?alt=media\&token=174d583f-1662-4cdc-b963-d73702c25541)

### Covariance

{% hint style="success" %}
It is a measure that quantifies the strength and direction of a relationship between a pair of variables.
{% endhint %}

$$
cov(x,y)=\frac{1}{n}\sum\_i^n(x\_i-\overline{x})(y\_i-\overline{y})
$$

### Correlation Coefficient

{% hint style="success" %}
The correlation coefficient, or **Pearson** product-moment correlation coefficient is another measure of the correlation between data. You can think of it as a **standardized covariance**.
{% endhint %}

$$
r\_{xy}=\frac{cov(x,y)}{\sigma(x)\sigma(y)}=\frac{\sum\_i^n(x\_i-\overline{x})(y\_i-\overline{y})}{\sqrt{\sum\_i^n(x\_i-\overline{x})^2\sum\_i^n(y\_i-\overline{y})^2}}
$$

> Make a Scatter Plot, and look at it! You may see a correlation that the calculation does not.
>
> **Correlation Is Not Causation** which says that a correlation does not mean that one thing causes the other.
