Covariance Matrix Calculator

Understand a sample covariance matrix before computing it

A sample covariance matrix summarizes how two or three measured series vary together across aligned observations. Returns from assets, scores from tests, readings from sensors, and other side-by-side measurements need more than separate averages: their paired departures from average can move together, move oppositely, or show little linear pattern. The matrix gathers those relationships in one numerical view.

This covariance matrix calculator accepts two or three equal-length numeric series and returns a sample covariance matrix. It estimates spread from a finite sample by using n − 1 as the denominator. Diagonal cells are the sample variances of individual series, while off-diagonal cells are pairwise sample covariances. The matrix is symmetric, so the covariance of Series 1 with Series 2 equals the covariance of Series 2 with Series 1.

Covariance is easiest to picture with a scatter plot. An upward-slanting cloud of paired points has positive covariance; a downward-slanting cloud has negative covariance; and a cloud with no evident tilt can have covariance near zero. This page converts comma-separated observations into that same quantitative summary.

Preparing aligned series for a covariance matrix

For this covariance calculation, each position across the entered series must identify the same observation. If Series 1 contains weekly advertising spend and Series 2 contains weekly sales, their first values must be from the same week, as must their second values and every later pair. The calculator uses list position as the alignment; it does not match dates, names, or labels.

Keep every populated series the same length. A list of eight Series 1 values and seven Series 2 values does not provide eight complete pairs, so it cannot produce a valid covariance estimate. The page checks the lengths and reports an error when they differ. Clean the lists before submitting: the parser retains valid comma-separated numbers and ignores invalid entries, so stray text or symbols can remove an observation and create an unexpected length mismatch.

The optional third list expands a 2 × 2 covariance matrix into a 3 × 3 matrix. It lets you examine one more feature against the first two, such as another market index, exam component, or engineering measurement. Rows and columns follow the entered field order: Series 1, Series 2, then Series 3 when it is populated.

Covariance matrix units depend on the original measurements. A variance has squared units, and a covariance has the product of the two series' units. Height in centimeters paired with weight in kilograms, for example, produces covariance in centimeter-kilograms. This scale dependence makes covariance useful for raw shared variation within a dataset, but less suitable for comparing unrelated pairs expressed on very different scales.

Sample covariance formula used for each matrix cell

This calculator first finds the mean of each entered series, then measures every observation's deviation from its own series mean. For each pair of series, it multiplies matching deviations, adds those products, and divides by n − 1. That calculation supplies every entry of the sample covariance matrix, including a variance when the same series appears on both sides.

cov (X,Y) = i=1 n (xi-x¯) (yi-y¯) n-1

With Series 1 and Series 2 only, the calculator prints a 2 × 2 matrix. Its top-left and bottom-right cells are the two sample variances, and its two off-diagonal cells repeat the same pairwise covariance. Supplying Series 3 produces a 3 × 3 matrix, adding the variance of Series 3 and the covariances for its pairs with the first two series.

Raw covariance changes with scale in a predictable way. Multiplying every Series 1 value by 10 multiplies its variance by 100 and its covariance with another series by 10. The calculator intentionally does not standardize series, so its result remains a plain sample covariance matrix. A correlation matrix is the usual next step when you need scale-free comparisons.

Interpreting covariance signs and matrix magnitudes

In this covariance matrix, the sign of an off-diagonal entry describes the direction of linear co-movement in the sample. Positive covariance means paired values often sit above their means together or below their means together. Negative covariance means one series often sits above its mean while the other sits below its mean. A value near zero indicates little linear association, but does not rule out a nonlinear relationship.

Pattern in paired data Typical covariance sign Plain-language reading
Points lean upward from left to right Positive When one variable is higher than usual, the other often is too.
Points lean downward from left to right Negative When one variable is higher than usual, the other is often lower than usual.
Points look roughly round or directionless Near zero There is little clear linear co-movement in the sample.

The magnitude of a covariance matrix entry needs its data context. A value of 50 can be large or small depending on the units and ranges of the two series. Compare signs, relative off-diagonal magnitudes, and diagonal variances within the same matrix. In a portfolio, a large positive covariance can indicate assets that tend to move together; in process data, a negative covariance can reveal a tradeoff between measurements.

Worked sample covariance matrix for three series

Enter Series 1 as 2, 4, 6, 8, Series 2 as 1, 3, 5, 7, and Series 3 as 8, 6, 4, 2. Their means are 5, 4, and 5. Once centered around those means, Series 1 and Series 2 have matching deviations, whereas Series 3 has the opposite deviation pattern. The first pair therefore has positive covariance, while Series 3 has negative covariance with both of the others.

Applying the sample covariance denominator of n − 1, each variance is 20/3, or about 6.666667. Series 1 with Series 2 is also 20/3. Series 1 with Series 3 and Series 2 with Series 3 are each −20/3.

[ 6.666667,  6.666667, -6.666667 ]
[ 6.666667,  6.666667, -6.666667 ]
[ -6.666667, -6.666667, 6.666667 ]

This covariance matrix illustrates two practical reading habits: inspect the diagonal for each series' own variability, then inspect off-diagonal cells for paired direction. Series 3 is the reverse of the other two in this deliberately simple set, which explains its negative pairwise covariances. Real data are rarely this exact, but the interpretation follows the same pattern.

Reading this calculator's covariance matrix output

After selecting Compute Covariance, the result panel prints the sample covariance matrix in field order. Two entered series produce two rows and columns; a populated optional third series produces three. The output is plain numeric text, making it convenient to copy into notes, a spreadsheet, or code.

When a covariance result looks unexpected, verify the aligned observations before questioning the arithmetic. Check that every populated list has the same number of valid numeric values, that matching positions describe the same observation, and that the series use consistent intended units. A dollars-versus-thousands-of-dollars mismatch, for example, changes the covariance magnitude substantially.

Limits and data checks for sample covariance

This covariance matrix tool calculates sample covariance, not population covariance, and divides by n − 1. Each populated series must therefore contain at least two numeric values. With one observation there is no sample spread to estimate, and the calculator reports that requirement directly.

Sample covariance can be sensitive to outliers. One extreme paired observation may noticeably change an off-diagonal matrix entry, particularly in a small dataset. If a result appears dominated by an unusual point, inspect the entered observations before treating the relationship as representative. Comparing results before and after correcting clear data-entry errors can be informative.

A covariance matrix describes co-movement in the supplied sample; it does not establish why the variables move together. Positive covariance does not show that one series causes another. Shared drivers, trends, seasonal patterns, or coincidence can all create an observed relationship, so use the matrix as a descriptive diagnostic rather than a causal conclusion.

For a useful sample covariance matrix, enter matched observations in consistent units and use enough observations to reflect the behavior of interest. Follow with correlation when comparisons across differently scaled variables matter. The matrix can also be an initial diagnostic for risk analysis, clustering, dimensionality reduction, and multivariate modeling.

Covariance mini-game: Eigen Align

This optional covariance visualizer turns paired observations into animated scatter clouds before you inspect a matrix entry. Align the sampling axis with each cloud's dominant tilt to practice recognizing positive and negative covariance. It does not alter the calculator's result.

Score0
Time75.0s
Streak0
Wave0
Lock0%

Eigen Align

Rotate the sampling axis until it matches the tilt of each scatter cloud. Drag anywhere on the plot or use the left and right arrow keys. Hold alignment to fill the lock meter before the wave escapes.

  • Each wave acts like a fresh paired dataset.
  • Upward clouds suggest positive covariance; downward clouds suggest negative covariance.
  • Later waves add rotation, outliers, and turbulence, so read the overall pattern instead of chasing a single point.

Best score: 0

Fast reminder: covariance comes from paired deviations around the mean, and the long axis of the cloud shows the strongest shared direction.

The game is separate from the calculator result, but it teaches the same visual idea behind the off-diagonal entries in a covariance matrix.

Enter aligned observations

Use commas between values. Keep the series lengths equal, and make sure each position across the lists refers to the same observation.

Example input: 2, 4, 6, 8. This calculator returns the sample covariance matrix, so every populated series must contain at least two valid numbers.

Enter two or three equal-length numeric series to evaluate the sample covariance matrix.

Embed this calculator

Copy and paste the HTML below to add the Sample Covariance Matrix Calculator for 2 or 3 Data Series to your website.