Math calculator

Covariance Matrix Calculator

The whole structure.

How variables move

Thirty-four properties: floor area, room count, age and asking price. The strongest pair is area against price at 0.90146, the condition number is 33.14, and the first principal direction holds 66.64% of the total variation — which is the “bigger and more expensive” axis that any property dataset has. The correlation determinant is 0.047962: well away from zero, so the matrix inverts cleanly and a regression or a distance computed from it will be stable. This is what an ordinary, usable covariance structure looks like.

34 observations · 4 variables

Condition number 33.14 — the variables overlap substantially

The correlation determinant is 0.047962, where 1 means nothing is correlated and 0 means some variable is an exact combination of the others. The first principal direction holds 66.64% of the total variation, and the strongest pair correlates 0.90146.

Condition number

33.14

largest over smallest eigenvalue

Correlation determinant

0.047962

1 when nothing is correlated

First direction

66.64%

share of total variation

Strongest pair

0.90146

floor area and price

Covariance

The sample covariance matrix, in the units of the variables multiplied together
Variablefloor arearoomsageprice
floor area551.183620.328042.1087417.6713
rooms20.32801.13733.643516.1255
age42.10873.6435273.8146-23.9173
price417.671316.1255-23.9173389.4758

The diagonal is each variable’s variance. Every entry carries the units of two variables multiplied together, so the numbers are not comparable across cells — which is exactly why the correlation matrix below exists and why the diagnostics are computed from it.

Correlation

The correlation matrix, with each covariance divided by the two standard deviations
Variablefloor arearoomsageprice
floor area1.00000.81190.10840.9015
rooms0.81191.00000.20650.7662
age0.10840.20651.0000-0.0732
price0.90150.7662-0.07321.0000

Bold entries exceed 0.8 in magnitude. A pairwise scan of this table is the usual check and it misses redundancy spread across three or more variables, which is what the eigenvalues below are for.

Independent directions

Eigenvalues of the correlation matrix and the share of variation each direction carries
DirectionEigenvalueShareCumulative
Direction 12.6657466.64%66.64%
Direction 21.0384225.96%92.60%
Direction 30.215415.39%97.99%
Direction 40.080442.01%100.00%

These sum to 4.000000, and with 4 variables they have to sum to exactly 4— the correlation matrix has a unit diagonal, so its trace is fixed. An eigenvalue near zero means one variable is nearly an exact combination of the others, and their product is the determinant: 0.047962.

Covariance measures how two variables move together in a straight line and nothing else. A perfect curved relationship can sit in this matrix as a covariance of zero, which is what distance correlation exists to catch.

Both matrices Eigenvalues and condition Trace checks itself Linear relationships only

What this tool shows

On the second preset every entry in the covariance matrix looks perfectly reasonable, and its smallest eigenvalue is 0.00004. Height has been recorded twice, centimetres in one column and inches in another. The condition number is 55,628.56 and the correlation determinant is 0.000066. Anything that inverts this matrix — a regression, a Mahalanobis distance, a multivariate test — divides by that eigenvalue and returns numbers with no error raised and no meaning.

  • The sample covariance matrix and the correlation matrix side by side, with the units divided out of the second
  • Eigenvalues of the correlation matrix, with each direction’s share of the total variation
  • The determinant and the condition number, which detect redundancy no pairwise scan can see
  • The strongest correlated pair named, and every entry above 0.8 marked
  • Presets covering an ordinary structure, a duplicated variable, diffuse redundancy, and genuine independence
  • Why the eigenvalues must sum to the number of variables, and what it means when one is near zero
Both matrices Eigenvalues and condition Trace checks itself Shares per direction

Covariance sees straight lines. Nothing else.

Updated 13 September 2026 · Works in any browser, no installation

A covariance matrix records how every pair of variables moves together; the correlation matrix is the same information with the units divided out, and its eigenvalues say how much genuinely independent information the set contains. Reading the matrix as a table of pairs is the usual approach and it misses the failure that matters most — redundancy spread thinly across three or four variables, where no single pair looks suspicious and the whole set is nearly one thing.

At a glance

Formula shown
Cov(X, Y) = Σ(xᵢ − x̄)(yᵢ − ȳ)/(n − 1), with the diagonal being each variable’s variance. Dividing each entry by the two standard deviations gives the correlation matrix, whose diagonal is 1 and whose eigenvalues therefore sum to p, the number of variables. Their product is the determinant: 1 when nothing is correlated, 0 when some variable is an exact combination of the others. The condition number is the largest eigenvalue over the smallest.
Scenario support
Checking a predictor set for redundancy before fitting anything, preparing the matrix a Mahalanobis distance or Hotelling test will invert, sizing up a dataset for dimension reduction, and portfolio work where the covariance between assets is the input rather than a diagnostic.
Educational estimate
Planning support from the values you enter — not professional advice.

The redundancy a pairwise scan cannot see

Scanning a correlation matrix for large entries is the standard check. The third preset is built so that check passes and the data is still badly redundant.

Five subject scores, and the strongest pair correlates 0.67007. Nothing anyone would stop on. No entry comes near the usual 0.8 or 0.9 alarm.

66.4941% of the total variation lies along a single direction. The correlation determinant is 0.089143 and the condition number is 12.32.

The five scores are largely one thing measured five ways, and the redundancy is spread evenly enough that no pair carries it.

Only the eigenvalues show this. Which is the argument for reading the matrix as a matrix rather than as a table of pairs — the pairwise view is a projection, and it loses precisely this.

A matrix that looks fine and cannot be inverted

The second preset is the failure that actually happens in practice, and the reason the condition number is printed at the top of the page rather than buried.

Height in centimetres and height in inches, in two columns. They correlate 0.999956, which is a rounding artefact away from 1.

The condition number is 55,628.56 and the smallest eigenvalue is 0.00004. The correlation determinant is 0.000066.

Nothing in the covariance matrix looks wrong. Every entry is finite, plausible, and correctly computed.

But inverting it divides by that smallest eigenvalue. A Mahalanobis distance on this data returns numbers; they are noise, and no error is raised. The fix is to drop one of the two columns, not to adjust a threshold.

Two checks that hold for every dataset

The eigenvalue table carries its own verification, which is printed on the page rather than left in the test suite.

The eigenvalues must sum to the number of variables. The correlation matrix has a unit diagonal, so its trace is fixed at p regardless of the data.

Their product must equal the determinant. Both are printed, and both are computed independently — the determinant by elimination, the eigenvalues by Jacobi rotations.

Between them those two identities pin down the whole decomposition. An error in either routine breaks one of them.

The verification suite asserts both on 120 generated datasets across two to five variables, alongside the requirements that the covariance matrix be symmetric, the correlation diagonal be exactly 1, and no correlation escape the range from −1 to 1.

Why the diagnostics use the correlation matrix

Both matrices are shown, and everything diagnostic on this page is computed from the second. That is a deliberate choice with a concrete reason.

Every covariance entry carries the units of two variables multiplied together. A covariance between metres and kilograms is in metre-kilograms, which is not comparable to anything else in the table.

So the eigenvalues of a covariance matrix depend on the units. Record a length in millimetres instead of metres and the first principal direction can change completely.

The correlation matrix has the scales divided out, so its eigenvalues describe the structure rather than the choice of units.

The same argument applies to principal components, which is why they are usually computed on the correlation matrix unless the variables genuinely share a unit and their relative magnitudes are meaningful.

It is an estimate, and a noisy one

A covariance matrix is usually treated as a known quantity once computed. It is a set of estimates, and the number of them grows quickly.

Ten variables means fifty-five distinct entries to estimate. p(p+1)/2 grows as the square, while the data available for each grows only with n.

With n close to p the matrix is badly conditioned by construction, whatever the true structure is — and when n is below p it is singular with certainty.

The eigenvalues are biased in a specific direction: the largest is overestimated and the smallest underestimated, which makes the condition number look worse than the truth and the first component look more dominant.

Shrinkage estimators exist for exactly this, pulling the matrix towards a simple target. This page reports the plain sample matrix, which is the right default and is worth knowing the limits of.

A covariance of zero is not independence

The last limitation is shared with every correlation coefficient, and it is the one most likely to be forgotten once the numbers are in a tidy grid.

Covariance measures how two variables move together in a straight line. That is the entire definition.

A perfect symmetric curve gives a covariance of exactly zero. The cell reads 0.0000 and the two variables determine each other completely.

So a matrix full of small entries is not evidence of independent variables. It is evidence of no linear relationships.

When that distinction matters, the measure to use is distance correlation, which is zero if and only if the variables are genuinely independent.

Reporting a covariance structure

Four items, and the second is the one that turns a matrix from a table into a usable diagnostic.

Give the correlation matrix rather than the covariance one unless the units matter to the reader. Covariances in mixed units are not comparable across cells.

Give the condition number or the smallest eigenvalue. It is what says whether anything downstream that inverts the matrix can be trusted.

Give n and p together. Ten variables on thirty cases is a different object from ten variables on three thousand, even with identical entries.

And say the relationships are linear ones. A near-zero cell rules out a straight line and nothing more.

Sources and methodology

References for the matrix and its diagnostics.

Method. Covariances use the n − 1 denominator, and the correlation matrix is formed from them rather than computed separately, so the two tables on the page are guaranteed consistent. Eigenvalues come from the cyclic Jacobi method on the correlation matrix, which is stable for symmetric matrices and converges to full precision at these sizes, while the determinant is computed independently by elimination — that independence is what makes the check meaningful. The verification suite asserts both identities on 120 generated datasets: the eigenvalues must sum to the number of variables, since the correlation matrix has a unit diagonal, and their product must equal the determinant. It also asserts symmetry, a correlation diagonal of exactly 1, and that no entry escapes the range from −1 to 1 — on the same 120. Sets with a constant column or more than twelve variables are refused rather than returned with degenerate entries. That engine is verified on every change against 90 assertions. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

Mahalanobis DistanceMultivariate outlier distance with the chi-square cutoff, each row's largest z-score beside it, and a count of the points only the joint screen finds.
Correlation CoefficientReports Pearson, Spearman and Kendall together with the scatter plot, and ships Anscombe's quartet built in — four datasets with an identical r of 0.816 that Spearman tells apart.
Hotelling T-SquaredOne-sample and two-sample multivariate mean tests with every single-variable t test printed alongside, so the joint answer can be compared against the alternative.
Multiple CorrelationMultiple R with adjusted R-squared, an F test, and a per-predictor table of simple, partial and unique contributions beside the variance inflation factors.
VarianceSample and population variance from your data, with a live simulation that shows exactly how much the wrong divisor costs — 20% low at n = 5, closing as the sample grows.
Distance CorrelationDistance correlation with a permutation test and Pearson's r on the same data, detecting curved and variance-based dependence that a correlation scores as zero.

More in Math, or browse all calculators.

Educational use disclaimer

An educational tool. The sample covariance matrix is a set of estimates whose count grows as the square of the number of variables, so with few observations relative to variables it is badly conditioned whatever the truth is, and its extreme eigenvalues are biased outward. Covariance measures linear association only — a near-zero entry rules out a straight line, not a relationship.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

What's changed (5 updates)

Published 13 September 2026

  1. Published the sample covariance and correlation matrices with eigenvalues, determinant and condition number.
  2. Shipped a preset where one variable appears twice in different units and the smallest eigenvalue is 0.00004.
  3. Added a preset where no pair correlates above 0.67007 and two thirds of the variation is one direction.
  4. Printed the eigenvalue sum against the number of variables, which is fixed by the unit diagonal.
  5. Stated that a near-zero entry rules out a straight line rather than a relationship.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.