Course contentsShow
← Data Science
Lesson 478 of 2,14513. Correlation AnalysisFree lesson

The Formula for Pearson's r

Breaking down the mathematical formula: covariance divided by the product of standard deviations.

The Formula for Pearson's r

You'll learn how Pearson's r is calculated as the ratio of covariance to the product of standard deviations.

Now that you understand what Pearson's correlation measures and how to interpret it, let's peek under the hood at the actual mathematical formula. Don't worry—it's more intuitive than it looks!

The Core Formula

Pearson's correlation coefficient (r) is calculated as:

r = covariance(X, Y) / (standard deviation of X × standard deviation of Y)

Or more formally:

r = Cov(X, Y) / (SD_x × SD_y)

Why This Formula Makes Sense

Think of covariance as the "raw" measure of how two variables move together. If X and Y both increase together, covariance is positive. If they move in opposite directions, it's negative.

But covariance alone is hard to interpret because it depends on the units of your variables. A covariance of 100 might be huge for variables measured in millimeters but tiny for variables measured in kilometers.

The denominator (the product of the two standard deviations) standardizes this raw covariance. It essentially asks: "How variable is each variable on its own?" By dividing covariance by this product, you create a unit-free number that always falls between -1 and +1.

Analogy: Imagine measuring how well two dancers coordinate. Covariance tells you they move together, but one dancer might naturally take bigger steps. Dividing by their individual step sizes gives you a fair comparison—a standardized "coordination score."

Key Takeaway: Pearson's r divides the covariance by the product of standard deviations to create a standardized, interpretable measure of linear association that always ranges from -1 to +1.