Energy Distance#
A distance between distributions used to test whether two samples differ.
Important
✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.
What it is#
Energy distance is a statistical distance between two probability distributions \(P\) and \(Q\), built from expected pairwise distances between samples. It is 0 exactly when the distributions are identical, and grows as they differ — making it a natural two-sample test, in the same family as MMD.
The formula#
For \(X \sim P\) and \(Y \sim Q\),
where \(X, X'\) are independent draws from \(P\), \(Y, Y'\) from \(Q\), and \(\|\cdot\|\) is the Euclidean norm. The empirical version replaces these expectations with averages over the two samples — cross-distances minus within-distances.
Properties#
It is a true metric: non-negative, symmetric, and zero iff \(P = Q\). Unlike MMD it is kernel-free, working directly with Euclidean distances, and like MMD it stays sensitive in high dimensions where the KS test fails. Both energy distance and MMD are integral probability metrics.
Where it’s used, with an example#
It serves two-sample testing, drift detection (training vs production), GAN evaluation and clustering validation. Comparing two customer-age distributions, an energy distance of 0.15 says they are fairly similar, while 1.2 signals a real difference — perhaps a much younger incoming sample.
Theme: Distribution Shift & Drift · All terminology
Hint
Mind map — connected ideas
Classifier Two-Sample Tests (C2STs) · Representation Shift · Drift Detection · Maximum Mean Discrepancy (MMD) · PSI (Population Stability Index) · Data Drift
Hint
More in Distribution Shift & Drift
Cardinality in Categorical Data · Categorical Drift · Categorical Explosions · Classifier Two-Sample Tests (C2STs) · Concept Drift · Covariate Drift (a.k.a. Covariate Shift) · Data Drift · Dataset Shift · Drift Detection · Drift Guardrails · Jensen–Shannon (JS) Divergence · KS shift (Kolmogorov–Smirnov shift) · Kullback–Leibler (KL) Divergence · Label Drift (a.k.a. Target Drift)
See also
Source article Adapted (context, re-expressed) in our own words from: Energy Distance (insightful-data-lab.com).