Let us begin by defining covariance before we dive into discussing how to calculate it. Covariance measures the directional relationship between the return on two assets.

### Types of Covariance.

The first one is the **positive covariance**. A positive covariance between two variables indicates that these variables tend to be higher or lower at the same time.

**Negative Covarianc**e. When the calculated covariance is less than negative, this indicates that the two variables have an inverse relationship.

### Application of Covariance.

We can use covariance to evaluate the risk of particular stocks by comparing whether they move with or against each other.

The covariance formula has applications in finance, majorly in portfolio theory. Thus, the assets can be chosen that do not exhibit a high positive covariance with each other and partially eliminating the unsystematic risk.

### Formula to Calculate Covariance.

x is the data value of x

y is the data value of y

μx is the mean of x

μy is the mean of y

N is the number of data values

**Example:**

Suppose an analyst observed the behavior of stock x and y. If the return of stock x is 2000 and the mean is 150, calculate the covariance if the return of stock y us 1500 and its mean is 120 when N is 5.

Since we already have the return in total, we do not need to do any summation, we will just plug our values in the formula.