Correlation Coefficient Calculator

Correlation Coefficient Calculator

Compare paired observations with Pearson, Spearman, Kendall, or Matthews correlation and inspect the underlying calculation.

Pearson correlation 5 complete pairs r = 0.7746

Workbook ready for the demonstration dataset.

Data

1
2
3
4
5

Results

Pearson correlation, r

0.7746

StrengthStrong
DirectionPositive
Complete pairs5

The sample shows a strong positive linear association.

Pearson correlation is 0.7746, strong positive, from 5 complete pairs.

Paired observations

Paired x-y observations

Five paired observations are plotted on their original scales. The point pattern provides a visual check for linearity, monotonic direction, clusters, and outliers.

Pearson calculation details

Calculation details are rebuilt from the same canonical values used by the headline result and Excel workbook.

How to use this correlation coefficient calculator

What this calculator does

This calculator measures the direction and strength of association between two paired variables. It supports four related statistics: Pearson correlation for linear association between quantitative values, Spearman correlation for monotonic association after ranking, Kendall rank correlation for concordance between ordered pairs, and Matthews correlation for agreement between two binary classifications. Correlation is a descriptive measure, not proof that one variable causes changes in the other, and a single coefficient cannot reveal every nonlinear pattern or data-quality issue. For Pearson's definition and formula, see the NIST correlation coefficient reference.

When to use it

Use the calculator when you want to check whether two measurements rise or fall together, compare an ordinal ranking with another ranking, quantify agreement in paired ordered scores, or evaluate the correspondence between actual and predicted binary labels. It is especially useful for a quick exploratory check before a regression or for validating a hand calculation. A scatter plot is shown for Pearson, Spearman, and Kendall modes because the pattern of the original paired observations can reveal curvature, clusters, and outliers that a coefficient alone can hide.

How to calculate

  1. The page opens with a five-pair demonstration dataset and a validated Excel workbook ready to download. Choose the Correlation coefficient that matches your data and analytical question.
  2. Set How many points (up to 30)? and replace each x and y value. Every active row must be complete. Standard decimal notation and scientific notation such as 1.2e3 are accepted; commas and mixed-unit text are rejected to avoid ambiguous parsing.
  3. If you select Kendall, choose a Kendall variant. Tau-a uses all possible pairs in the denominator, tau-b adjusts for ties in x or y, and tau-c additionally accounts for the smaller of the two category counts.
  4. Use Show calculation details? to display or hide the method-specific table. The headline result and the Excel export always use the same underlying model whether the table is visible or not.
  5. Read the coefficient with the Strength, Direction, and Complete pairs cards, then inspect the scatter plot when it is applicable. Choose Download Excel to export the current valid state. Reset clears the demonstration values, restores neutral controls, removes calculated output, and disables export until at least three complete valid pairs produce a finite coefficient again.

Input guide

Correlation coefficient is required and chooses Pearson, Spearman, Kendall, or Matthews. How many points (up to 30)? is required and accepts an integer from 3 through 30. The x values and y values are required numeric collections: for example, the startup x values are 1, 2, 3, 4, 5 and the y values are 2, 4, 5, 4, 5. Increasing or changing any observation can change both the magnitude and direction of the coefficient. Do not paste values with commas as thousands separators because this calculator intentionally uses a dot as the decimal separator. In Matthews mode, every x and y value must be exactly 0 or 1; x is treated as the observed class and y as the predicted class. Kendall variant is required only in Kendall mode. Show calculation details? is optional and changes presentation only, not the statistic.

Output guide

The primary Correlation coefficient is unitless and normally lies from -1 to +1. Strength describes the absolute magnitude using broad descriptive bands: very weak below 0.2, weak from 0.2 to below 0.4, moderate from 0.4 to below 0.6, strong from 0.6 to below 0.8, and very strong from 0.8 through 1. Direction reports positive, negative, or none from the sign. Complete pairs is the exact number of active paired rows. The method-specific detail table shows the terms that feed the selected formula: deviations for Pearson, average ranks for Spearman, concordant/discordant and tie counts for Kendall, or the TP/FN/FP/TN confusion-matrix counts for Matthews. The Paired observations scatter plot uses the same x-y rows and is a diagnostic picture rather than a separate estimate.

Worked example

The startup example uses x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5 with Pearson correlation selected. The means are x̄ = 3 and ȳ = 4. The cross-deviation sum is 6, the squared x-deviation sum is 10, and the squared y-deviation sum is 6. Pearson's formula therefore gives r = 6 ÷ √(10 × 6) = 0.7745966692, displayed as 0.7746. Its absolute value falls in the strong band and the sign is positive, so the first-open interpretation is Strong and Positive. The scatter plot contains exactly those five points, and the downloaded workbook records the same typed values rather than rounded screen text.

How the four correlation methods differ

Pearson correlation standardizes the covariance of x and y by their variation. It is sensitive to a linear relationship and can be strongly affected by outliers. A low Pearson value does not rule out a curved relationship, which is why examining the paired-data plot is important. Penn State's regression notes emphasize that Pearson's r is unitless, bounded between -1 and +1, and describes the strength of a linear relationship.

Spearman correlation first converts both variables to ranks, using average ranks for ties, and then computes Pearson correlation on those ranks. That makes it useful when the relationship is monotonic but not linear or when ranks are more meaningful than raw distances. The NIST Spearman reference describes the same rank-then-correlate approach and notes its usefulness for ranked or nonlinearly related measurements.

Kendall correlation counts whether pairs of observations are concordant or discordant. Tau-b adjusts for one-variable ties and is usually the safest default when ties occur in ordinal data. Tau-c is useful for rectangular contingency structures with different numbers of possible x and y categories. The SciPy Kendall tau documentation gives the standard tau-b and tau-c definitions used here.

Matthews correlation treats x as observed binary labels and y as predicted binary labels. The result combines true positives, true negatives, false positives, and false negatives in one balanced coefficient. The scikit-learn MCC documentation explains why MCC can be informative even when the two classes are imbalanced.

Formula and interpretation cautions

Pearson: r = Σ[(x – x̄)(y – ȳ)] / √(Σ(x – x̄)² × Σ(y – ȳ)²)

A coefficient is undefined when the selected formula has a zero denominator, such as when every x value is identical in Pearson mode or when a binary label has no variation in Matthews mode. The calculator reports that state instead of producing NaN or Infinity, and Excel export remains blocked until the data produce a finite result. Descriptive strength labels are only heuristics; what counts as a practically important correlation depends on the subject area, measurement reliability, sample size, study design, and the cost of acting on the relationship. Correlation should be combined with visual inspection and domain knowledge rather than treated as a standalone decision rule.