Four matrix cells and four marginal counts
TP and TN count correct positive and negative predictions; FP counts false alerts and FN missed positives. The marginal sums count predicted positives, actual positives, actual negatives and predicted negatives. Each of these sets must be nonempty here. The numerator compares products of correct and incorrect assignments. Denominator normalization turns this into a correlation value between −1 and +1.[2][3]
This differs from the F1 score, which omits true negatives. Considering both actual classes can be especially useful when class sizes differ. That does not make MCC automatically independent of prevalence or universally appropriate as an objective. Nor does it measure probability calibration: hard class decisions in a single matrix are insufficient for that.[2][1]
Why the formula is a correlation
Encode actual class as X and prediction as Y, with 1 for positive and 0 for negative. The empirical distribution gives each of N cases equal weight. The mean of X is actual-positive frequency; the mean of Y is predicted-positive frequency; the mean of XY is true-positive frequency.[3]
These are empirical proportions from the same cases.[3]
Expanding with N = TP + FN + FP + TN gives the MCC numerator.[3]
A binary variable with empirical fraction p has variance p(1 − p). Insert actual-positive and predicted-positive frequencies into the two variances. In covariance divided by the square root of their product, factors of N2 cancel, leaving the formula with four marginal sums. A constant variable has zero variance, which prevents using this correlation definition.[3]
Example 1: calculate MCC in full
An original matrix of 100 cases
- Given
- TP = 40, FN = 10, TN = 45 and FP = 5 come from the same binary test evaluation.
- Find
- Find numerator, marginal sums and MCC.
Calculate the difference between the two cross-products.
Find the four marginal sums and their positive normalization.
Divide after taking the square root.
Result: MCC is about +0.704. The empirical association is positive but not perfect.
Check: The matrix totals 100. Both actual and predicted classes are represented, and all marginal sums are positive. Existing errors rule out perfect agreement.
Recall the method later with the formula’s flashcards.
10 flashcards · English materials
Already have an account? Sign in for flashcardsAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Example 2: understand a negative sign
Inverse predictions and deliberate reversal
- Given
- A constructed case has TP = 5, TN = 5 and FP = FN = 45. For a second comparison, only predicted labels are swapped while actual labels remain fixed.
- Find
- Find MCC before and after this one-sided reversal.
All four marginal sums equal 50. The product of error counts dominates.
Reversing predictions turns previous false negatives into true positives and previous false positives into true negatives.
The new numerator has opposite sign with unchanged normalization.
Result: Reversing prediction labels alone changes the sign. Merely relabelling both actual and predicted classes together is different and leaves MCC unchanged.
Check: Initially 10 of 100 predictions are correct; after reversal 90 are correct. The signs match inverse and positive association. This is not a recommendation to invert an unexamined real model.
Zero, constant classes and conclusions you cannot draw
With a defined denominator, MCC = 0 means the empirical cross-product difference vanishes. It proves neither a particular random mechanism nor 50% accuracy. A single value also does not establish association in a larger deployment population. Test size, case selection and reference labels are part of the evaluation. Small datasets remain uncertain even when the arithmetic on the supplied counts is fully reproducible.[2]
If an actual or predicted class is constant, at least one marginal sum is zero and the ordinary correlation formula is undefined. Software or theoretical extensions can impose additional conventions. This page’s calculator reports undefined explicitly instead of inventing an observed correlation. An always-negative model is one example, even if many negative test cases give it high accuracy.[3]
Balanced Accuracy instead averages the two actual-class detection rates equally. With both actual classes present, a constant prediction can give it 0.5 while MCC correlation is undefined due to absent prediction variation. The metrics therefore describe different properties; their numbers should not be interchanged as though they were the same scale.
The calculator uses only unweighted nonnegative integer TP, FP, TN and FN with a total at most 9,007,199,254,740,991. This is a technical counting limit rather than a statistical minimum sample size. Multiplying every count by the same positive factor scales numerator and denominator quadratically, leaving MCC unchanged. Merely copying the same test cases does not supply additional independent observations. The theoretical cross-product reconstruction from MCC and marginal sums does not add an inverse calculator target.[3][2]
Five exercises on binary correlation
Calculate · Application
Calculate MCC for TP = 30, FN = 10, FP = 10 and TN = 50.
Show hint
The marginal sums are two 40s and two 60s.
Learning goal: Evaluate cross-products and marginal sums separately.
Show solution and calculation
The numerator is 1500 − 100 = 1400.
The denominator is √(40 × 40 × 60 × 60) = 2400.
Hence MCC = 7/12 ≈ 0.5833.
Error analysis · Application
In the previous exercise, the numerator 1400 is divided by the product 5,760,000. What is missing?
Show hint
Check the denominator structure in the original formula.
Learning goal: Apply the square root to the whole product correctly.
Show solution and calculation
The square root over the product of all four marginal factors is missing.
The correct denominator is 2400, not 5,760,000.
Division must occur after taking that square root.
Interpret · Application
With TP = 4, FP = 6, FN = 16 and TN = 24, MCC is zero. Check whether accuracy must therefore be exactly 50%.
Show hint
Compare the vanishing cross-product difference with the count of correct cases.
Learning goal: Avoid equating zero correlation with a fixed overall accuracy.
Show solution and calculation
TP × TN and FP × FN both equal 96, giving a zero MCC numerator.
Accuracy is instead (4 + 24)/50 = 56%.
Zero correlation does not fix that overall proportion.
Rearrange · Application
All four marginal sums are 50 and exact MCC is 0.60. Find TP × TN − FP × FN.
Show hint
Multiply MCC by the square root of the marginal product.
Learning goal: Recover the numerator from a given MCC and positive normalization.
Show solution and calculation
Normalization is √(504) = 2500, so the numerator is 0.60 × 2500 = 1500.
One compatible matrix has TP = TN = 40 and FP = FN = 10, whose cross-product difference really is 1500.
Transfer · Challenge
Every case from example 1 is copied identically three times into the same evaluation. Does MCC change, and does this create three independent test sets?
Show hint
Every count is multiplied by 3, every cross-product by 9.
Learning goal: Distinguish scale invariance of a score from new statistical information.
Show solution and calculation
The numerator scales by 9, and the denominator by √(34) = 9, leaving MCC unchanged.
Identical copies are not new independent observations and cannot justify the uncertainty reduction associated with genuinely new independent test cases.
Check your understanding with the formula’s reference test.
7 test questions · English materials
Already have an account? Sign in for the testAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Sources for this explanation
Quanta · Updated November 21, 2026
- Foody (2023), Challenges in the real world use of classification accuracy metrics, prevalence and reference-standard quality
- scikit-learn documentation: matthews_corrcoef, binary correlation and range
- Chicco and Jurman (2020), The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy in binary classification evaluation, Methods
Editorial responsibility: Quanta Study editorial team
Review scope
This explanation, 2 worked examples and 5 exercises are available in German and English. Structure, source references and mathematical notation undergo automated checks. Calculations, model assumptions and both language versions receive a separate AI review.
An independent, named human subject review has not yet been documented. Our exercise numbers are worked examples, rather than measurements published by the cited sources.
Editorial responsibility, sources and methodsChange history
- Clarified binary-correlation count limits and scaling; titled five matching tasks and excluded an overlapping German MC option.
- Derived MCC as binary correlation; added two original examples, five exercises and limits of degenerate matrices.
Cite this reference page
Quanta. Matthews correlation coefficient (MCC). Updated November 21, 2026. https://quanta-study.de/en/formula-sheet/matthews-korrelationskoeffizient
When citing a specific scientific statement, also cite the specialist source linked to that statement.