Covariance Calculator
This covariance calculator computes covariance between variables using multiple methods suited to different data availability scenarios: raw paired lists, aggregated summaries, correlation with standard deviations, and full multivariate covariance matrices.
The tool explicitly supports both sample (unbiased) and population estimators, provides numerically stable computation strategies for large datasets, and surfaces basic diagnostics such as sample size and algorithm notes to help you assess reliability.
Calculate covariance from two comma-separated lists of observations. Supports sample (unbiased) and population estimators and uses a numerically stable one-pass or two-pass algorithm depending on input size.
Inputs
Advanced inputs
Paired lists input
Correlation and standard deviations
Summary statistics input
Multivariate matrix input
Results
Covariance (X,Y)
—
Number of observations
—
Mean of X
—
Mean of Y
—
Computation note
—
| Output | Value | Unit |
|---|---|---|
| Covariance (X,Y) | — | unit_x × unit_y |
| Number of observations | — | — |
| Mean of X | — | — |
| Mean of Y | — | — |
| Computation note | — | — |
Visualization
Methodology
For raw paired data, the calculator parses comma-separated lists and computes means and cross-deviations. By default it uses the sample estimator (dividing by n-1) when you select 'Sample'. For very large datasets a one-pass numerically stable algorithm is used to avoid catastrophic cancellation.
When only summary statistics are available, the calculator computes covariance from sums and counts using algebraic identities. When correlation and standard deviations are provided, covariance is computed as rho × σx × σy. For multivariate inputs it returns the full covariance matrix with the same estimator choice applied to each covariance term.
Worked examples
Example 1: From paired lists. X = 1,2,3,4,5 and Y = 2,4,6,8,10 with sample estimator returns covariance = 5.
Example 2: From correlation. If ρ = 0.8, σx = 2 and σy = 3 then covariance = 0.8 × 2 × 3 = 4.8.
Example 3: Multivariate. Paste a CSV with observations as rows to get a covariance matrix for all variables.
Further resources
External guidance
Expert Q&A
Should I use the sample or population estimator?
Use the sample (dividing by n-1) when your data is a sample drawn from a larger population and you want an unbiased estimator of the population covariance. Use the population estimator (dividing by n) when your input contains the entire population of interest.
How does numerical stability affect results?
When values are large or variances are small, naive two-pass subtraction can lose precision. For large datasets this tool switches to or recommends a one-pass numerically stable algorithm consistent with IEEE 754 floating point handling to reduce rounding errors.
Can I compute covariance from only correlation and standard deviations?
Yes. Covariance can be recovered from Pearson correlation and the standard deviations of each variable using covariance = ρ × σx × σy. Ensure the correlation is Pearson's correlation and standard deviations match the estimator type intended.
What checks are performed on input?
The calculator validates that paired lists have equal lengths, checks for non-numeric entries, and warns if the sample size is small. For aggregated inputs it requires at least one observation, and for sample estimators it requires more than one observation.
Are results exact or approximate?
Results are subject to floating-point rounding and the chosen estimator. For reproducible, high-precision needs use validated statistical software and consider higher-precision arithmetic. See the citations for recommended standards and testing.
Sources & citations
- NIST Engineering Statistics Handbook — https://www.itl.nist.gov/div898/handbook/
- ISO 3534 Statistics — Vocabulary and symbols — https://www.iso.org/standard/3534.html
- IEEE Standard for Floating-Point Arithmetic (IEEE 754) — https://standards.ieee.org/standard/754-2019.html
- OSHA - General industry standards (data handling and workplace practices) — https://www.osha.gov/laws-regs