Statistics & probability

Distance correlation independence test calculator for paired vectors

Measure dependence between paired vector observations using centered pairwise distances.

Your numbers

Whole number from 99 through 1999; the plus-one p-value cannot be zero.
Positive integer seed; repeating the same data and seed repeats the permutations.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Measure dependence between paired vector observations using centered pairwise distances. The distance-correlation coefficient can reveal nonlinear association that a simple linear correlation misses, while a seeded row permutation evaluates an independence null.

THE FORMULAA_ij=a_ij−a_i·−a_·j+a_··; V²=mean(A_ij B_ij); R²=V²/√(mean A² mean B²).

A worked example

The default pairs X=−4,…,4 with Y=X². Symmetry makes the ordinary linear correlation zero, even though Y is determined by X. The biased sample distance correlation is 0.500268; a finite permutation result is reported separately from the coefficient.

Good to know

6–150 independent paired rows,1–5 features per side. Biased double-centered Euclidean distance covariance; constant/unresolved distance variance rejected. 99–1999 seeded permutations of one side; no serial or cluster correction, unbiased estimator, population equality certificate or causal direction.

Paired observations differ from two independent samples

Row i of the first matrix must describe the same subject or experimental unit as row i of the second matrix. The two sides may have different numbers of features, but their row counts and subject order must agree.

This pairing is the information being tested. Independently sorting the two matrices can manufacture or erase association while leaving their marginal distributions unchanged. A two-sample energy test instead compares distributions without this row-by-row paired interpretation.

Paired distances detect a relation with zero linear covarianceY = X²dCor = 0.5003Nonlinear pairing
Scroll across to see the full diagram.
The default pairs X=−4,…,4 with Y=X². Symmetry makes the ordinary linear correlation zero, even though Y is determined by X. The biased sample distance correlation is 0.500268; a finite permutation result is reported separately from the coefficient.

Compare this with the Canonical correlation calculator for two variable sets. Canonical correlation measures linear combinations;distance correlation targets a different dependence functional.

Center distances rather than raw feature coordinates

The algorithm forms all Euclidean pairwise distances separately for the two sides. Each distance matrix is centered by subtracting its row mean and column mean and adding the grand mean, producing a representation of relative pairwise geometry.

The covariance statistic is the average elementwise product of these centered matrices. This version includes their diagonals and is a biased V-statistic. It should not be numerically compared without adjustment to an unbiased U-centered estimator using different diagonal and denominator conventions.

Normalization makes the coefficient dimensionless

The two distance-variance quantities normalize the cross quantity. Taking the appropriate square root yields a distance-correlation coefficient between zero and one up to numerical tolerance, so the final coefficient has no physical unit.

A constant sample has zero distance variance, making this normalization undefined. The calculator rejects that case instead of calling it zero dependence. Very small but unresolved variation is likewise not enough to support a reliable ratio of numerical quantities.

The parabola example explains nonlinear dependence

For symmetric predictor values minus four through four and squared responses, positive and negative predictors have equal responses. Their signed linear products cancel, so ordinary linear covariance is zero. Distance correlation remains about 0.5003.

That positive value reflects the paired distance structure, not a fitted quadratic regression. The page does not choose or estimate a predictive function. A nonlinear association summary and a model for predicting Y from X are related but different analytical tasks.

Permutation breaks only the submitted pairing

The randomization shuffles subject labels on the second centered distance matrix while keeping its two indices aligned. This preserves both marginal sample geometries and breaks the correspondence between the first and second observations.

The same seed and data order reproduce the finite permutation p-value. The plus-one counting convention prevents a zero result and makes its resolution explicit. The coefficient itself does not depend on the seed or number of randomizations.

Nonzero sample correlation is not a population proof

Finite independent samples can have positive biased distance correlation even under independence. That is why the coefficient is accompanied by a permutation comparison rather than being treated as a yes-or-no logical certificate of dependence.

The theoretical population property requires appropriate moment conditions and does not eliminate finite-sample uncertainty. A non-significant test can reflect limited sample size, weak effects or feature scaling, rather than establish that every possible relationship between the variables is absent.

Scale and exchangeability remain practical assumptions

Multiplying a whole side by a positive constant cancels in the normalized coefficient, but changing relative scales among that side’s features changes its Euclidean geometry. Feature selection and preprocessing should therefore be reported as part of the analysis.

The supported permutation assumes independent subject pairs that are exchangeable under the null. Time series, repeated measures and family clusters need an appropriate dependence-aware test. Neither coefficient magnitude nor permutation rejection supplies a causal direction or a subject-level decision rule.

A few questions, answered

Can the two sides have different feature counts?

Yes. Their feature dimensions can differ, but subject rows must align exactly.

Why can a parabola have nonzero distance correlation?

Pairwise distance geometry can retain nonlinear association even when signed linear covariance cancels.

Why reject a constant sample?

Its distance variance is zero, so the normalized coefficient is undefined.

Does the seed change the coefficient?

No. It changes only the sampled permutation p-value, not the observed distance-correlation statistic.

Find your calculator

Start typing to explore the library.