Correlation and Covariance Calculator
Our free statistics calculator solves correlation covariance problems. Get worked examples, visual aids, and downloadable results.
Reviewed for accuracy by Manoj Kumar, Mathematics Educator
Correlation and Covariance Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: r = Sum[(xi - x_mean)(yi - y_mean)] / sqrt[Sum(xi - x_mean)^2 * Sum(yi - y_mean)^2]
Worked example โ r = 0.9956 (Very Strong Positive) | Sample Cov = 75 | R-squared = 99.12%
Formula
r = Sum[(xi - x_mean)(yi - y_mean)] / sqrt[Sum(xi - x_mean)^2 * Sum(yi - y_mean)^2]
The Pearson correlation coefficient is calculated by dividing the sum of the products of deviations from the means by the geometric mean of the sums of squared deviations. Covariance uses the same numerator but divides by N (population) or N-1 (sample).
Worked Examples
Example 1: Height and Weight Correlation
Problem:Given heights (cm): 160, 165, 170, 175, 180 and weights (kg): 55, 62, 68, 72, 80, calculate the correlation and covariance.
Solution:Mean X = 170, Mean Y = 67.4 Deviations: (-10,-12.4), (-5,-5.4), (0,0.6), (5,4.6), (10,12.6) Sum of dx*dy = 124+27+0+23+126 = 300 Sum dx^2 = 100+25+0+25+100 = 250 Sum dy^2 = 153.76+29.16+0.36+21.16+158.76 = 363.2 Sample Cov = 300/4 = 75 Pearson r = 300 / sqrt(250 x 363.2) = 300/301.33 = 0.9956
Result:r = 0.9956 (Very Strong Positive) | Sample Cov = 75 | R-squared = 99.12%
Example 2: Study Hours vs Exam Score
Problem:Study hours: 2, 4, 6, 8, 10 and exam scores: 50, 55, 70, 80, 90. Find correlation.
Solution:Mean X = 6, Mean Y = 69 Sum dx*dy = (-4)(-19)+(-2)(-14)+(0)(1)+(2)(11)+(4)(21) = 76+28+0+22+84 = 210 Sum dx^2 = 16+4+0+4+16 = 40 Sum dy^2 = 361+196+1+121+441 = 1120 Pearson r = 210 / sqrt(40 x 1120) = 210/211.66 = 0.9922
Result:r = 0.9922 (Very Strong Positive) | More study hours strongly predict higher scores
Frequently Asked Questions
What is the difference between correlation and covariance?
Correlation and covariance both measure the relationship between two variables, but they differ in scale and interpretation. Covariance measures the directional relationship between two variables and can take any value from negative infinity to positive infinity. Its magnitude depends on the units of measurement, making it difficult to compare across different datasets. Correlation, specifically Pearson correlation, is a standardized version of covariance that always falls between -1 and +1. It is calculated by dividing the covariance by the product of the two standard deviations. This normalization makes correlation unitless and directly comparable across any pair of variables regardless of their scales. A correlation of +1 means perfect positive linear relationship, -1 means perfect negative, and 0 means no linear relationship.
How do I interpret the Pearson correlation coefficient?
The Pearson correlation coefficient r ranges from -1 to +1 and measures the strength and direction of a linear relationship between two variables. Values close to +1 indicate a strong positive relationship where both variables increase together. Values close to -1 indicate a strong negative relationship where one variable increases as the other decreases. Values near 0 suggest no linear relationship. Common interpretation thresholds are: 0.9 to 1.0 is very strong, 0.7 to 0.9 is strong, 0.5 to 0.7 is moderate, 0.3 to 0.5 is weak, and below 0.3 is very weak or negligible. However, context matters greatly. In physics, correlations below 0.95 might be considered poor, while in social sciences, correlations above 0.5 are often considered strong. Remember that correlation does not imply causation.
What is the difference between population and sample covariance?
The difference between population and sample covariance lies in the denominator used for calculation. Population covariance divides the sum of products of deviations by N (the total number of data points), assuming you have measured every member of the population. Sample covariance divides by N-1 instead, applying what is known as Bessel correction. This correction compensates for the fact that a sample tends to underestimate the true population variance because the sample mean is closer to the sample data points than the true population mean would be. When working with data from experiments, surveys, or any subset of a larger group, you should use the sample covariance (N-1). Population covariance is only appropriate when you have data for the entire population. For large datasets, the difference becomes negligible.
What is the coefficient of determination (R-squared) and what does it tell us?
The coefficient of determination, commonly written as R-squared, is the square of the Pearson correlation coefficient. It represents the proportion of variance in one variable that is explained or predicted by the other variable. R-squared ranges from 0 to 1 (or 0% to 100%). For example, an R-squared of 0.85 means that 85% of the variation in variable Y can be explained by its linear relationship with variable X, while the remaining 15% is unexplained variation due to other factors or random noise. In regression analysis, R-squared is a key metric for assessing model fit. Higher values indicate the regression line fits the data more closely. However, a high R-squared alone does not validate a model since it can be artificially inflated by adding more variables.
When should I use Spearman rank correlation instead of Pearson correlation?
Spearman rank correlation should be used instead of Pearson correlation in several situations. First, when the relationship between variables is monotonic but not necessarily linear, Spearman captures this better because it measures rank-order association. Second, when your data contains significant outliers, Spearman is more robust because converting values to ranks reduces the influence of extreme values. Third, when variables are measured on ordinal scales (like satisfaction ratings from 1 to 5), Spearman is more appropriate since it does not assume interval-level measurement. Fourth, when the data violates normality assumptions required by Pearson, Spearman provides a non-parametric alternative. Pearson is preferred when the relationship is truly linear and data is normally distributed with no major outliers, as it uses more information from the data and is statistically more powerful in those conditions.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator ยท Editorial policy
Related Calculators
๐งฎCorrelation Calculator
Calculate correlation with inputs, formulas, and instant results.
๐งฎScatter Plot Correlation Calculator
Calculate Pearson and Spearman correlation coefficients from paired data with significance test.
๐งฎCovariance Calculator
covariance calculator. Get instant, accurate results.
๐งฎAnnulus Area Calculator
Calculate annulus area with inputs, formulas, and instant results.
๐งฎArea Calculator
Calculate area with inputs, formulas, and instant results.
๐งฎArea of a Rectangle Calculator
Calculate the area, perimeter, and diagonal of a rectangle. Find missing sides from known area. Convert between metric and imperial area units.
๐งฎArea of Crescent Calculator
Calculate area of crescent with inputs, formulas, and instant results.
๐งฎCenter of Mass Calculator
Calculate center of mass with inputs, formulas, and instant results.