Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Covariance
course content

Course Content

Learning Statistics with Python

CovarianceCovariance

Covariance is a measure of the joint variability of two random variables.

The value of covarianceMeaning
PositiveTwo variables move in the same direction
0Two variables no linear relationship
NegativeTwo variables move in opposite directions

The formulas are different for the sample and population, but we will not dive deeper into them. In this chapter, we will discuss covariances of the following dataset:

Store_IDStore_AreaItems_AvailableDaily_Customer_CountStore_Sales
001659196153066490
111461175221039820
221340160972054010
331451174862053730
441770211145046620
  • Store_ID - The unique id of the store.
  • Store_Area - The area of the store.
  • Items_Available - The number of items that are available in the store.
  • Daily_Customer_Count - The daily number of customers in the store.
  • Store_Sales - The number of sales in the store.

Calculating Covariance with Python:

To compute covariance in Python, you can use the np.cov() function from the NumPy library. It requires two parameters: the sequences of data for which you want to calculate the covariance.

The result is the value at index [0,1]. This course won't cover the other values in the output, refer to the example:

This indicates that the values move in the same direction. This makes sense because a larger store area corresponds to a greater number of items. One significant drawback of covariance is that the value can be infinite.

Everything was clear?

Section 4. Chapter 1
some-alt