Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
What is Covariance? | Covariance and Correlation
course content

Зміст курсу

Probability Theory Basics

What is Covariance?What is Covariance?

Covariance is a numerical measure that quantifies the relationship between two variables.
It measures how changes in one variable correspond to changes in another variable. More specifically, covariance measures the joint variability of two variables and provides insights into the direction (positive or negative) of this variability.

Covariance calculation

  1. Conduct the first stochastic experiment several times and write the results of each experiment to the array. It will be an x array;
  2. Conduct the second stochastic experiment several times and write the results to the y array;
  3. Calculate covariance using the numpy library: covariance = np.cov(x, y)[0, 1].

Examples

We see that as the value of x increases, the value of y also increases. The correlation is, therefore, positive. Let's provide another experiment:

Now while the x value increases, the y value decreases and the covariance is negative. Now let's look at the covariation between the results of two independent experiments:

As a result, we can make a conclusion:

  1. If the covariance between two values is positive then with increasing of the first value the second value also increases;
  2. If the covariance between two values is negative then with increasing of the first value the second value decreases;
  3. If values are independent then they have zero correlation (are uncorrelated).

Pay attention to the last point: the correlation is zero if the values ​​are independent. But the converse is not true: if the correlation is zero, this does not mean independence. Look at the example:

The points in the example above lie inside the unit circle and are therefore dependent but uncorrelated.
In general, only linear relationships between values ​​can be well identified with the help of covariance. Thus, in the case of uncorrelated values, we can conclude that they do not have linear dependencies, but may have other more complex types of dependencies.

Which of the following statements is true?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 5. Розділ 1
course content

Зміст курсу

Probability Theory Basics

What is Covariance?What is Covariance?

Covariance is a numerical measure that quantifies the relationship between two variables.
It measures how changes in one variable correspond to changes in another variable. More specifically, covariance measures the joint variability of two variables and provides insights into the direction (positive or negative) of this variability.

Covariance calculation

  1. Conduct the first stochastic experiment several times and write the results of each experiment to the array. It will be an x array;
  2. Conduct the second stochastic experiment several times and write the results to the y array;
  3. Calculate covariance using the numpy library: covariance = np.cov(x, y)[0, 1].

Examples

We see that as the value of x increases, the value of y also increases. The correlation is, therefore, positive. Let's provide another experiment:

Now while the x value increases, the y value decreases and the covariance is negative. Now let's look at the covariation between the results of two independent experiments:

As a result, we can make a conclusion:

  1. If the covariance between two values is positive then with increasing of the first value the second value also increases;
  2. If the covariance between two values is negative then with increasing of the first value the second value decreases;
  3. If values are independent then they have zero correlation (are uncorrelated).

Pay attention to the last point: the correlation is zero if the values ​​are independent. But the converse is not true: if the correlation is zero, this does not mean independence. Look at the example:

The points in the example above lie inside the unit circle and are therefore dependent but uncorrelated.
In general, only linear relationships between values ​​can be well identified with the help of covariance. Thus, in the case of uncorrelated values, we can conclude that they do not have linear dependencies, but may have other more complex types of dependencies.

Which of the following statements is true?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 5. Розділ 1
some-alt