Karl Pearson Coefficient of Correlation

|
13 min read
|
116 views
Karl Pearson Coefficient of Correlation

Students waste many hours trying to learn how to find r. Then they get r = 0.43, and don’t know what to do with it.

This is the actual issue with pretty much all of the articles on this topic. They show you how to use the formula, provide four ways of calculation, and that’s it – exactly at the point where the value starts being useful

This guide goes further. You will get not only the formula, but also four ways of calculation with real-life examples using relevant data (not fictional ‘series X / series Y’), a proper interpretation guide, the list of assumptions required before calculations, and the answer to the question no one else answers: when to use another method for calculating correlation?

What Is Karl Pearson’s Coefficient of Correlation?

Coefficient of Correlation devised by Karl Pearson determines the degree of association between two variables. Pearson formulated the mathematical equation in 1896, based on the earlier research conducted by Francis Galton on regression – but it was Pearson who lent numerical accuracy to the concept, making it reproducible on any set of data.

The coefficient is symbolized by ‘r’. It is a pure number; there is no unit, no dimension – just a figure lying between −1 and +1.

And that is precisely why it is so handy; you can compare r-coefficients even when the data sets are entirely different.

What the r value tells you:

r ValueMeaning
+1Perfect positive linear relationship — as X increases, Y increases proportionally
0No linear relationship (non-linear patterns may still exist)
−1Perfect negative linear relationship — as X increases, Y decreases proportionally

This technique has a more formal title, which is the “Pearson Product-Moment Correlation Coefficient” (PPMCC). This is the title that appears in scientific publications. “Simple Correlation Coefficient” is not an alternative title but rather a term used at the textbook level.

Karl Pearson Coefficient of Correlation

The Karl Pearson Correlation Formula

The core formula is:

r=∑xy∑x2×∑y2r = \frac{\sum xy}{\sqrt{\sum x^2 \times \sum y^2}}r=∑x2×∑y2​∑xy​

Or equivalently, using the covariance form:

r=Cov(X,Y)σx×σyr = \frac{Cov(X, Y)}{\sigma_x \times \sigma_y}r=σx​×σy​Cov(X,Y)​

Both forms calculate the same value. The covariance form is more common in statistics and data science contexts; the deviation-product form is more common in textbooks and exam settings.

Variable Definitions

SymbolPlain-English MeaningHow to Calculate It
rThe correlation coefficientFinal output
NNumber of paired observationsCount the data pairs
xDeviation of each X from the meanx = X − X̄
yDeviation of each Y from the meany = Y − Ȳ
ΣxySum of products of deviationsMultiply each x by its paired y, then sum all
Σx²Sum of squared deviations of XSquare each x value, then sum all
Σy²Sum of squared deviations of YSquare each y value, then sum all
σxStandard deviation of X√(Σx² / N)
σyStandard deviation of Y√(Σy² / N)
Cov(X,Y)Covariance between X and YΣxy / N

How to Interpret Your r Value

The point is, this is the part that justifies the entire computation. Two conflicting articles that address this topic provide an r value, for example, “moderate positive correlation,” and go on to discuss something else. What is needed here is 

Jacob Cohen’s standards, commonly used in social sciences research, which provide the following scale:

Absolute r ValueInterpretation
0.00 – 0.10Negligible
0.10 – 0.30Weak
0.30 – 0.50Moderate
0.50 – 0.70Strong
0.70 – 1.00Very strong

However, the cut-off points will vary depending on the discipline. For example, r = 0.7 may be deemed insufficient in physics and engineering. Meanwhile, in social sciences, r = 0.4 is often used as an acceptable level. It will all depend on the situation.

The sign shows the direction. The magnitude shows the strength.

Moreover, r = 0 does not indicate that the variables are not related. Instead, it indicates that there is no linear correlation between them. A highly curved correlation, for example, a parabola, may result in r ≈ 0 even though the relationship is clear from the scatterplot. This is the most frequently misinterpreted characteristic of Pearson’s r.

Another important thing to note: Correlation ≠ Causation. For instance, ice-cream sales and drowning rate have a positive correlation in summer months since they both increase due to temperature, rather than the former causing the latter.

Karl Pearson Coefficient of Correlation

4 Methods to Calculate Karl Pearson’s Coefficient of Correlation

Prior to doing any computations, choose an appropriate technique based on the following table. This crucial step is completely omitted in all the other articles available on this topic – precisely what the readers need first.

MethodBest ForUse WhenComplexity
Actual Mean MethodSmall datasets, clean meansX̄ and Ȳ are whole numbersLow
Direct MethodRaw data, skip computing meansYou want to work with raw values directlyLow–Medium
Assumed Mean MethodLarge values or fractional meansActual mean produces messy decimalsMedium
Step Deviation MethodGrouped data with uniform intervalsData has constant class widthMedium

Method 1 — Actual Mean Method

When to apply it: The data is whole numbers and not too large to work with manually.

Steps:

  • Calculate X̄ and Ȳ (mean of both sets)
  • Find deviation: x = X − X̄ and y = Y − Ȳ
  • Calculate Σxy, Σx², and Σy²
  • Use formula

Formula:

r=xyx2×y2r=xyx2×y2r=x2×y2xyr=∑xy∑x2×∑y2r = \frac{\sum xy}{\sqrt{\sum x^2 \times \sum y^2}}r=∑x2×∑y2​∑xy​

Worked Example — Study Hours vs. Exam Scores:

A teacher records hours studied (X) and exam marks (Y) for 5 students:

StudentX (Hours)Y (Marks)x = X − X̄y = Y − Ȳxy
A240−2−14284196
B350−1−44116
C4550+1001
D560+1+66136
E665+2+11224121
Total20270006010370

X̄ = 20/5 = 4, Ȳ = 270/5 = 54

r=6010×370=603700=6060.83≈0.986r = \frac{60}{\sqrt{10 \times 370}} = \frac{60}{\sqrt{3700}} = \frac{60}{60.83} \approx \mathbf{0.986}r=10×370​60​=3700​60​=60.8360​≈0.986

Conclusion: Extremely high positive correlation. Those students that spend more hours studying score significantly higher marks on this test. As a side note, this is a very small sample size of only 5; a much larger data set would need to be examined.

Section Summary: When the means are clearly divided, use this technique. Means with decimals make the deviation columns difficult to calculate.

Method 2 — Direct Method (Raw Score Formula)

When to use it: You want to skip computing means and work directly with the raw data values.

Formula:

r=NXYXYNX2(X)2×NY2(Y)2r=NXYXYNX2(X)2×NY2(Y)2r=NX2(X)2×NY2(Y)2NXYXYr=N∑XY−∑X⋅∑YN∑X2−(∑X)2×N∑Y2−(∑Y)2r = \frac{N\sum XY – \sum X \cdot \sum Y}{\sqrt{N\sum X^2 – (\sum X)^2} \times \sqrt{N\sum Y^2 – (\sum Y)^2}}r=N∑X2−(∑X)2​×N∑Y2−(∑Y)2​N∑XY−∑X⋅∑Y​

No deviations. No means. Just five sums — ΣX, ΣY, ΣX², ΣY², ΣXY — and the formula handles everything else.

Worked Example — Monthly Advertising Spend vs. Sales Revenue:

MonthX (₹000 Spend)Y (₹000 Sales)XY
January1010010010,0001,000
February1212014414,4001,440
March1413019616,9001,820
April1615025622,5002,400
May1816032425,6002,880
Total706601,02089,4009,540

N = 5

Numerator: (5 × 9,540) − (70 × 660) = 47,700 − 46,200 = 1,500

Denominator:

  • √[(5 × 1,020) − 70²] = √[5,100 − 4,900] = √200 = 14.14
  • √[(5 × 89,400) − 660²] = √[447,000 − 435,600] = √11,400 = 106.77

r=1,50014.14×106.77=1,5001,509.7≈0.994r = \frac{1,500}{14.14 \times 106.77} = \frac{1,500}{1,509.7} \approx \mathbf{0.994}r=14.14×106.771,500​=1,509.71,500​≈0.994

Interpretation: Very strong positive correlation between expenditure on advertisements and total revenue generated. Every thousand rupee rise in expenditure on advertisement is very strongly associated with proportional rise in total revenue generated — although no control was maintained over seasonal or promotional variations.

Section summary: The Direct Method is usually the quickest method in case of small integers. In case of large numbers with decimal means, continue reading.

Method 3 — Assumed Mean Method (Short-Cut Method)

When should you use it? Your true mean value is a decimal such as X̄ = 24.7, making the deviations column a mess of fractions.

But there’s an easy solution to that problem. Simply choose any nice round figure close to your true mean as your assumed mean (A). Label the deviations as dx = X – A and dy = Y – B. Your formula takes care of the rest.

Formula:

r=NdxdydxdyNdx2(dx)2×Ndy2(dy)2r=NdxdydxdyNdx2(dx)2×Ndy2(dy)2r=Ndx2(dx)2×Ndy2(dy)2Ndxdydxdyr=N∑dxdy−∑dx⋅∑dyN∑dx2−(∑dx)2×N∑dy2−(∑dy)2r = \frac{N\sum dxdy – \sum dx \cdot \sum dy}{\sqrt{N\sum dx^2 – (\sum dx)^2} \times \sqrt{N\sum dy^2 – (\sum dy)^2}}r=N∑dx2−(∑dx)2​×N∑dy2−(∑dy)2​N∑dxdy−∑dx⋅∑dy​

Worked Example — Height vs. Weight (Group Data):

PersonX (Height cm)dx = X − 170Y (Weight kg)dy = Y − 65dxdydx²dy²
1160−1055−10100100100
2165−560−5252525
31700650000
4175+572+7352549
5180+1078+13130100169
Total0+5290250343

N = 5, A = 170, B = 65

Numerator: (5 × 290) − (0 × 5) = 1,450 − 0 = 1,450

Denominator:

  • √[(5 × 250) − 0²] = √1,250 = 35.36
  • √[(5 × 343) − 5²] = √[1,715 − 25] = √1,690 = 41.11

r=1,45035.36×41.11=1,4501,453.7≈0.997r = \frac{1,450}{35.36 \times 41.11} = \frac{1,450}{1,453.7} \approx \mathbf{0.997}r=35.36×41.111,450​=1,453.71,450​≈0.997

Interpretation: Perfect positive correlation between height and weight. Observe how selection of A=170 and B=65 made sure that all deviations were minimized and easily manageable whole numbers; that is exactly what the technique aimed at accomplishing.

Conclusion: Always select the assumed mean such that it lies nearest to the center of the distribution. It does not have to be precise; just any number would do to make calculations easy.

Method 4 — Step Deviation Method

When to use it: When data contains uniform class intervals like 10, 20, 30, 40 or when dealing with grouped frequency distribution.

Deviations from both variables are divided by a constant C to obtain small step deviations as: dx’ = (X – A)/C and dy’ = (Y – B)/C.

Formula:

r=NdxdydxdyNdx2(dx)2×Ndy2(dy)2r=NdxdydxdyNdx2(dx)2×Ndy2(dy)2r=Ndx2(dx)2×Ndy2(dy)2Ndxdydxdyr=N∑dx′dy′−∑dx′⋅∑dy′N∑dx′2−(∑dx′)2×N∑dy′2−(∑dy′)2r = \frac{N\sum dx’dy’ – \sum dx’ \cdot \sum dy’}{\sqrt{N\sum dx’^2 – (\sum dx’)^2} \times \sqrt{N\sum dy’^2 – (\sum dy’)^2}}r=N∑dx′2−(∑dx′)2​×N∑dy′2−(∑dy′)2​N∑dx′dy′−∑dx′⋅∑dy′​

r remains unchanged when divided by C. It is due to the Change of Scale property that whenever we multiply or divide each number by any constant, the correlation coefficient does not get affected. The Step Deviation Method is actually nothing but the Assumed Mean Method along with one more step.

Quick Example:

Data: X = {100, 110, 120, 130}, Y = {45, 50, 60, 65}, C = 10

Xdx’ = (X−115)/10Ydy’ = (Y−55)/10dx’dy’dx’²dy’²
100−1.545−1.01.502.251.00
110−0.550−0.50.250.250.25
120+0.560+0.50.250.250.25
130+1.565+1.01.502.251.00
Total003.505.002.50

r = (4 × 3.50) − 0 / [√(4 × 5.00 − 0) × √(4 × 2.50 − 0)] r = 14 / [√20 × √10] = 14 / [4.47 × 3.16] = 14 / 14.12 ≈ 0.991

Assumptions of Karl Pearson’s Coefficient of Correlation

In my opinion, the assumptions section is more important than the formulas section because knowing when not to apply a certain technique is as crucial as knowing when to apply it – and none of the two competing articles mentions any such conditions.

  1. Linear relationship between X and Y. Pearson’s coefficient of correlation measures the strength of a linear relationship. If the scatter diagram reveals a U shape, an S shape, or any other nonlinear relationship, the value of r will underestimate the strength of the true relationship, sometimes leading to nearly zero correlation where there obviously is one. Plot first, compute after.
  2. Continuous data at interval or ratio scale Both variables must be continuous and measured on an appropriate numerical scale allowing arithmetic operations. Applying Pearson’s correlation coefficient to ordinal data (such as 1-5 Likert scales) is statistically wrong; Spearman’s coefficient should be used instead.
  3. No extreme outliers serious. An outlier can bring r down from 0.85 to 0.30 – or even raise a value of r close to zero to 0.60. One outlier may make your weak relationship appear important, or your strong relationship seem unimportant. Graph your data first before running correlation.
  4. Bivariate normality (for significance testing) When you want to test for statistical significance of your r rather than just describe it, the two variables need to be normally distributed. This assumption is less stringent when you use correlation for descriptive purposes.
Karl Pearson Coefficient of Correlation

Properties of Karl Pearson’s Coefficient of Correlation

  1. Range: r is always between -1 and +1. r can never exceed this range. If you obtain a value of r as 1.3, it is definitely wrong. Arithmetic mistake!
  2. No units. R is unit-free. Whether X is in rupees, kilograms, or seconds, r remains unaffected. Thus, it can be compared with other sets of observations.
  3. Change of origin and scale doesn’t affect r. Any value obtained from r can be added, subtracted, multiplied, or divided by a constant without changing r. That is why the Assumed Mean Method and Step Deviation Method will give the same value as that of the Actual Mean Method.
  4. Symmetry of r. r(X, Y) = r(Y, X). It does not matter whether you take X on the y-axis or vice versa.
  5. r = 0 does not imply independence. Absence of linear correlation does not imply absence of association. Even a perfect parabola will give r = 0.

Merits and Demerits of Karl Pearson’s Coefficient of Correlation

Merits:

  • Indicates both the direction and magnitude of the relationship using one figure – simple and convenient
  • Unaffected by any scaling and shifting of the data – it does not depend on the scale used
  • Mathematically sound (covariance divided by the product of standard deviations)
  • Most frequently reported measure of correlation in academic literature

Demerits:

  • It assumes linearity — totally incorrect when dealing with any form of non-linearity
  • Very sensitive to outliers; an outlying point can totally alter the outcome
  • Needs continuous data; cannot be used on categorical or ordinal data
  • Time-consuming if done manually with large samples
  • It may create a false sense of relationship if not pre-tested with scatter plots

Karl Pearson vs. Spearman Rank Correlation — Which Should You Use?

Actually, the framing of “which is better” is the wrong question. The right question is which assumptions your data satisfies. That determines the method — not preference.

Your SituationUse Pearson’s rUse Spearman’s ρ
Data typeContinuous, interval/ratio scaleOrdinal, ranked, or non-normal
Relationship shapeConfirmed linearMonotonic (doesn’t have to be linear)
OutliersNone or fewPresent
Sample size / distributionLarge, approximately normalSmall or skewed

Short answer: if your variables are continuous, you see a linear relationship on the scatter plot, and you have no outliers – use Pearson. In all other cases – use Spearman.

Believe it or not, but in practice almost all cases require using Spearman correlation coefficients rather than the cases we learn about in basic statistics classes. Customer surveys, rankings, and preferences should always be analyzed using Spearman correlation coefficient.

How to Calculate Karl Pearson’s Correlation in Excel and Python

Using Excel

The CORREL function handles the entire calculation from raw data. One line.

=CORREL(A2:A10, B2:B10)

A2:A10 is your X data range and B2:B10 is your Y data range. The function returns r directly. No intermediate columns needed.

Using Python

Two options depending on what you need back from the calculation:

Option 1 — scipy.stats.pearsonr() — returns r plus the p-value:
from scipy import stats

x = [2, 3, 4, 5, 6]
y = [40, 50, 55, 60, 65]

r, p_value = stats.pearsonr(x, y)
print(f”r = {r:.3f}”)
print(f”p-value = {p_value:.4f}”)

Option 2 — numpy.corrcoef() — returns a full correlation matrix:

python
import numpy as np

x = [2, 3, 4, 5, 6]
y = [40, 50, 55, 60, 65]

matrix = np.corrcoef(x, y)
r = matrix[0, 1]
print(f"r = {r:.3f}")

Use SciPy’s pearsonr when you also want the p-value to test significance. Use numpy when you’re working with multiple variables and want a full correlation matrix in one step.

Solved Examples

Example 1 — Actual Mean Method: Temperature vs. Ice Cream Sales

A shop owner records daily maximum temperature (°C) and ice cream units sold over 6 days:

DayX (Temp °C)Y (Units Sold)x = X−X̄y = Y−Ȳxy
12580−5−24.212125585.6
22890−2−14.228.44201.6
3301000−4.20017.6
432110+2+5.811.6433.6
535125+5+20.810425432.6
6301200+15.800249.6
Total1806250265581,520.6

X̄ = 180/6 = 30, Ȳ = 625/6 ≈ 104.2

r=26558×1,520.6=26588,194.8=265297≈0.892r = \frac{265}{\sqrt{58 \times 1,520.6}} = \frac{265}{\sqrt{88,194.8}} = \frac{265}{297} \approx \mathbf{0.892}r=58×1,520.6​265​=88,194.8​265​=297265​≈0.892

Interpretation: There is a very strong positive correlation. As the temperature rises, the sales of ice cream also rise; r = 0.892 belongs to the group of “very strong.” But as I have to say definitely, it is not the only factor that leads to the increased sales. There were other uncontrolled factors.

Example 2 — Interpretation Focus: What r = −0.78 Actually Tells You

A study was conducted by a researcher to establish the relationship between weekly hours spent on screen viewing and the quality of sleep rated from 1 to 10 by 25 participants, resulting in a correlation coefficient of r = −0.78.

Let us interpret it systematically step-by-step:

  • Direction (negative): As screen viewing hours increase, there is a corresponding decrease in sleep quality. The variables move in opposite directions.
  • Magnitude (0.78): Highly strong according to Cohen’s guidelines. This cannot be considered a merely statistically significant finding.
  • Statistical Significance: For a sample size of n = 25, the critical value of r at p < 0.05 is approximately 0.396. Therefore, r = −0.78 is much higher than this value.
  • Hold on. The quality of sleep was measured using a 1 to 10 rating scale. Ordinal scale. The use of Spearman’s rank correlation would have been more suitable here.

It is such an insightful analysis that differentiates someone who knows how to calculate correlation from one who understands it.

Frequently Asked Questions

Q1. What is the range of Karl Pearson’s coefficient of correlation? 

Ans. The coefficient of correlation, Karl Pearson’s r always takes values from −1 to +1. A value of +1 indicates perfect positive correlation, −1 indicates perfect negative correlation, while a value of 0 indicates no linear relation between the two variables.

Q2. What does r = 0 mean for Pearson’s correlation? 

Ans. If r = 0, it implies that there is no linear correlation between X and Y. But r = 0 doesn’t imply independence of X and Y. In case of a highly curvilinear or non-linear relation between two variables, the value of r may be close to zero.

Q3. What is the difference between Pearson and Spearman correlation? 

Ans. The correlation measure by Karl Pearson assumes that the relationship between the two variables is linear and that there are no extreme outliers in the data set. Spearman’s rank correlation coefficient is preferred when the above assumptions are violated.

Q4. What are the important assumptions regarding Karl Pearson’s coefficient of correlation? 

Ans. Four main assumptions: (1) linear relationship between X and Y; (2) both X and Y are measured on a continuous scale; (3) absence of outliers; (4) both variables must be normally distributed for significance testing purposes.

Q5. How is Karl Pearson’s r affected by changes in scale or origin? 

Ans. Not at all. Multiplication/division of all values of either X or Y by any constant (scale change) does not affect r. Addition/subtraction of a constant (origin change) similarly has no effect. It is thanks to this property that the Assumed Mean Method and the Step Deviation Method can give the same result as the Actual Mean Method.

Q6. What constitutes a high/strong value of Karl Pearson’s coefficient of correlation? 

Ans. There is no such thing as a universally accepted cutoff point. On Cohen’s scale: 0.1–0.3 is weak, 0.3–0.5 is moderate, 0.5–0.7 is strong, and anything over 0.7 is very strong. The most important point is that what constitutes a strong coefficient depends on your area of research. For psychology, r = 0.4 is already considered a significant correlation, whereas in precision engineering, r > 0.95 may be needed.

Most data projects fail not due to poor coding, but due to the fact that someone created the wrong structure prior to writing a single line of code, and by the time this became obvious, fixing it meant rewriting half the project.

And this is precisely the problem that data modeling solves. Yet, every article on the subject allocates 90% of its pages to definitions and very little (if any) to the practical question that people want answered: which technique should I use, and when?

This guide will provide you with all the definitions that you need in no time, and a framework that data teams usually learn through costly trial-and-error experience.

Shalki Aggarwal is a Software Engineer II at Microsoft and an AI & Data Science expert specializing in Generative AI, Agentic AI, Python, LangChain, LangGraph, CrewAI, Deep Agents, and Loop Engineering. She is also a corporate trainer for leading organizations including L&T, Bharat Petroleum, Luminous, Denso, and Toshiba Midea, helping teams apply AI and emerging technologies to real-world business challenges.