Covariance Calculator
Calculate sample and population covariance, Pearson correlation, and visualize data with a scatter plot. Supports bulk data paste and CSV input.
| # | X | Y |
|---|
About
Covariance quantifies the joint variability between two random variables X and Y. A positive value indicates both variables tend to increase together. A negative value indicates an inverse relationship. A value near zero suggests no linear dependence. The distinction between sample covariance (dividing by n โ 1) and population covariance (dividing by n) is not cosmetic. Using the wrong denominator on a sample biases your estimate downward, which propagates errors into portfolio risk models, regression coefficients, and principal component analyses. This calculator computes both forms, derives the Pearson correlation coefficient r, and renders a scatter plot with the least-squares regression line so you can visually verify linearity assumptions before trusting the number.
Limitations: covariance captures only linear association. Two variables with a strong quadratic or periodic relationship can return Cov ≈ 0. Always inspect the scatter plot. The tool assumes paired observations of equal length and does not handle missing data interpolation. For time-series with lag structure, consider cross-covariance functions instead.
Formulas
The sample covariance between paired observations X and Y of size n is computed as:
For population covariance, replace the denominator with n. The Pearson correlation coefficient normalizes covariance by the product of standard deviations:
The least-squares regression line Y = b0 + b1X uses slope:
Where = arithmetic mean of X, = arithmetic mean of Y, sX = sample standard deviation of X, sY = sample standard deviation of Y, n = number of paired observations.
Reference Data
| Measure | Symbol | Range | Interpretation |
|---|---|---|---|
| Population Covariance | ฯXY | (โโ, +โ) | Joint variability; scale-dependent |
| Sample Covariance | sXY | (โโ, +โ) | Unbiased estimator using Bessel correction |
| Pearson Correlation | r | [โ1, +1] | Normalized; +1 perfect positive, โ1 perfect negative |
| Variance (X) | s2X | [0, โ) | Spread of X around its mean |
| Standard Deviation (X) | sX | [0, โ) | Square root of variance; same units as X |
| Mean (X) | (โโ, +โ) | Arithmetic average of X observations | |
| Mean (Y) | (โโ, +โ) | Arithmetic average of Y observations | |
| Sum of Products | SP | (โโ, +โ) | ฮฃ(xi โ )(yi โ ) |
| Coefficient of Determination | r2 | [0, 1] | Proportion of Y variance explained by X |
| Regression Slope | b1 | (โโ, +โ) | Change in Y per unit change in X |
| Regression Intercept | b0 | (โโ, +โ) | Predicted Y when X = 0 |
| Spearman Rank Correlation | ฯs | [โ1, +1] | Monotonic association; robust to outliers |
| Correlation Strength | |r| < 0.3 | - | Weak linear relationship |
| Correlation Strength | 0.3 โค |r| < 0.7 | - | Moderate linear relationship |
| Correlation Strength | |r| โฅ 0.7 | - | Strong linear relationship |