How this calculation works
Kendall tau-b measures whether paired observations tend to agree in their relative ordering. It compares every pair of observation rows, counting concordance when both variables move in the same direction and discordance when they move in opposite directions. Marginal ties change the normalization so repeated ranks do not receive a fabricated order. This page shows each tie category and the resulting score. It separately offers tie-adjusted normal inference or exact permutation inference for a small no-tie sample.
tau-b=(C−D)/sqrt((C+D+Tx)(C+D+Ty)), with Tx and Ty counting ties in only one variable.A worked example
For x=(1,2,3,4) and y=(1,2,4,3), five of the six observation pairs are concordant and one is discordant. There are no ties, so tau-b=(5−1)/6=2/3. Exact two-sided inference counts how often an untied random permutation has an absolute score at least four. Replacing y by repeated values would change both the pair counts and denominator; an exact no-tie procedure would then be inappropriate and the page requires the tie-adjusted approximation instead.
Good to know
Matched finite sequences of 2–500 observations; a constant variable makes tau-b undefined and raises an error. Asymptotic inference uses the full marginal tie correction without continuity adjustment. Exact two-sided enumeration supports at most nine pairs and rejects all tied samples. Numeric values are compared as entered, without tolerance-based rank merging. No partial correlation, missing-data deletion, causal conclusion or inference for clustered/nonindependent pairs is supplied.
Reference: SciPy — Kendall tau-b pair counts, ties and inference (opens in a new tab) ↗
Joint ties and marginal ties play different roles
A pair tied in x but not y cannot be concordant or discordant, yet it still affects the x-side normalization. A pair tied in both variables contributes no ordering information in either direction. The table separates these cases so the denominator can be checked rather than compressing every tie into one number. Tau-b reduces to the familiar untied tau-a formula only when both marginal tie counts vanish.
Only order matters: any strictly increasing transformation of one variable preserves the pair categories. A strictly decreasing transformation reverses their signs. The coefficient therefore does not measure the size of numeric differences, the agreement of units, or a regression slope. Identical ordering can yield tau-b one even when one variable is a nonlinear transformation of the other. Constant data are an exception because no comparable order remains and the denominator is zero.
Inference depends on sample size and the tie pattern
The normal approximation is applied to the score C−D, with variance corrections based on the sizes of tied groups in each variable. Treating all observations as untied can overstate or understate the amount of information. The displayed variance and z statistic make this convention visible. A small approximate p-value remains conditional on independent paired observations; repeated measurements from the same person need an analysis that respects their dependence.
Exact mode enumerates untied permutations and compares absolute score extremeness. Its factorial sample space explains the nine-pair limit. Ties would require a different exact conditional procedure, so the page rejects them rather than reusing the untied count. The Spearman rank correlation with ties calculator instead correlates numeric ranks; both are ordinal association measures, but they summarize pair agreement differently and need not have the same coefficient or p-value.
A few questions, answered
Should I break ties by adding tiny random values?
No. That changes the observed ordering and the null variance. Tau-b includes tie categories explicitly; use its supported asymptotic inference when ties are present.
Does tau-b zero prove independence?
No. It indicates balanced concordance and discordance under this ordinal summary. Nonmonotone dependence can remain even when the coefficient is near zero.