How this calculation works
Compare two multivariate empirical distributions with an energy-distance statistic. A seeded permutation test reallocates pooled observations between samples while preserving both sample sizes, providing a reproducible finite-randomization p-value.
E²=2 mean_(i,j)||X_i−Y_j||−mean_(i,i′)||X_i−X_i′||−mean_(j,j′)||Y_j−Y_j′||; p=(1+b)/(B+1).A worked example
The example compares two four-point squares in two features, with the second square translated by (2,0.5). The biased empirical energy distance is 1.633539. With 199 permutations and seed 12345, the plus-one p-value is 0.030000; changing the seed can change that Monte Carlo result.
Good to know
At least 2 rows per sample,≤150 total observations,1–5 shared features. Euclidean distance and biased V-statistic including zero self-distances. 99–1999 seeded permutations with fixed sample sizes. Independent observations and exchangeability under the null required. No feature standardization, weights, causal conclusion or exact exhaustive p-value.
Reference: Székely and Rizzo energy-statistics paper (opens in a new tab) ↗
Compare whole empirical distributions in a common feature space
Energy distance compares between-sample distances with the distances observed inside each sample. A location shift, spread difference or other distributional change can alter this balance, so the calculation is not restricted to comparing two means.
Every feature must have a meaningful shared scale across both samples. A variable measured in thousands can dominate Euclidean distances beside one measured in fractions. The page does not secretly standardize columns, because that would change the submitted mathematical problem.
Compare this with the Wasserstein distance calculator for two samples. Wasserstein transport cost does not produce the energy statistic or this permutation test.
This version uses a biased empirical V-statistic
The within-sample averages include every ordered pair, including each observation paired with itself at distance zero. Their denominators are therefore n squared and m squared rather than n times n minus one and m times m minus one.
The nonnegative squared energy statistic is reported separately from its square root. Other packages may expose an unbiased U-statistic or a sample-size-scaled test statistic. Compare formulas and denominators before deciding that differently labeled numerical outputs disagree.
Permutations preserve sample sizes and the pooled geometry
Under the exchangeability null, pooled observation labels can be reassigned without changing their joint distribution. The implementation shuffles indices, retains the first n observations as one sample and assigns the remainder to the other sample.
It precomputes all pairwise distances, so each permutation changes labels rather than recalculating a different geometry. This still assumes independent sampling units. Shuffling rows from paired, clustered or serially dependent data without a suitable design would not implement this null correctly.
The shifted-square default separates distance from significance
The two four-point samples each form a unit square in two dimensions. Translating the second by two horizontal units and half a vertical unit changes cross-sample distances while retaining both within-sample distance patterns. The reported energy distance is about 1.6335.
The permutation p-value answers how often a relabeling gives at least that large a statistic within this finite randomization. It is not a probability that the two population distributions are equal, and it does not convert the geometric distance into a causal effect size.
The plus-one p-value has a visible resolution
The page counts b permuted statistics at least as large as the observed statistic and reports (b+1)/(B+1). Including the observed arrangement in this convention prevents a simulated p-value of zero when none of the sampled permutations exceed it.
With 199 replications, the smallest possible displayed value is one two-hundredth. Increasing the replication count refines Monte Carlo resolution but does not add subjects, fix unrepresentative sampling or guarantee that a population difference will be detected.
Reproducibility requires the data and the seed
The integer seed determines the pseudorandom shuffle sequence. Reusing a seed with unchanged row order and unchanged data reproduces the calculation. Reordering input observations can change sampled relabelings even when the underlying energy distance is invariant.
A seed is not a quality score or a parameter to tune until a preferred p-value appears. If comparing several seeds to understand simulation variability, report that exploratory procedure honestly and use an adequate preselected replication budget for formal work.
Interpret rejection and nonrejection with the design
A small permutation p-value is evidence against the exchangeability null under the chosen statistic and data design. A large one does not establish distributional equivalence; small samples can leave important differences undetected.
Outliers, scale choices and duplicated or dependent records can strongly affect pairwise distances. Inspect those inputs and the study design before an applied conclusion. The calculator supplies no automatic multiple-testing correction, confidence interval or domain-specific decision threshold.
A few questions, answered
Are features standardized automatically?
No. Euclidean distance uses the entered coordinate scales, so scaling choices must be explicit.
Why is the p-value never zero?
The plus-one rule reports (b+1)/(B+1), including the observed arrangement in its convention.
Is the reported distance the squared statistic?
Both are returned separately; the energy distance is the square root of the nonnegative V-statistic.
Can I shuffle paired or clustered rows as ordinary samples?
Not under this independent-sample permutation design; dependent units need an appropriate restricted randomization.