AI Glossary / Statistics and probability / Advanced

Ball divergence

Definition

Ball divergence is a statistical measure of how two probability distributions differ, constructed by comparing the probability they assign to collections of metric balls. A metric ball contains points within a specified distance of its center. Its empirical version supports nonparametric two-sample testing, including comparisons involving multivariate observations and suitable non-Euclidean data.

What it means

Two groups can have the same average while differing in spread, shape, or dependence among their measurements. A comparison focused only on means can overlook these changes.

Ball divergence examines local neighborhoods instead. If a neighborhood contains a large proportion of one group's observations but a small proportion of the other's, that provides evidence of a distributional difference. Combining such discrepancies across many neighborhoods produces an overall measure.

The distance definition is part of the analysis. For ordinary numerical data, Euclidean distance may be suitable after justified scaling. For shapes, directions, or other structured objects, a scientifically meaningful metric may be required. Arbitrary distances do not automatically inherit every theoretical guarantee.

How it works

For the basic two-sample empirical construction, take each ordered pair of observations within the first sample. Use the first observation as the center and the distance to the second as the radius of a closed ball.

Calculate the fraction of first-sample observations in that ball and the fraction of second-sample observations in it. Square their difference, then average across all such ordered pairs, including diagonal pairs. Repeat with balls defined by ordered pairs within the second sample and add the two averages.

The corresponding population construction compares probabilities assigned to balls. Under the metric-space conditions established for the method, equality of distributions is characterized by zero population divergence. A finite-sample statistic can be positive even when both groups share one population distribution.

A permutation test compares the observed statistic with values obtained by reallocating group labels under the null. This requires the relevant exchangeability assumptions. Serial dependence, paired observations, or clustered sampling can invalidate unrestricted permutations. Software also offers weighting and multi-sample extensions; the exact statistic and calibration must be identified when reporting results.

Three practical examples

  • Model monitoring: compare the multivariate distribution of incoming customer features with a reference period to investigate potential input drift.
  • Manufacturing: compare measurements from two production settings when differences might involve variability or joint structure rather than only average dimensions.
  • Shape analysis: compare two collections of geometric objects using an appropriate shape distance, without flattening every object into an arbitrary scalar summary.

Think of it this way

Think of laying many transparent circles over two colored sets of points. In each circle, compare the proportion of each color captured. Ball divergence combines those local differences. In higher dimensions or other metric spaces, the neighborhoods need not resemble circles drawn on paper.

Worked example

Consider first-sample values X = {0, 1} and second-sample values Y = {2, 3}, using absolute distance. Each sample has four ordered center-radius pairs.

For X, the balls have center and radius (0, 0), (0, 1), (1, 1), and (1, 0). The squared differences between the X and Y proportions are respectively 0.25, 1, 0.25, and 0.25. For example, the closed ball centered at 1 with radius 1 contains both X values and Y's value 2, producing (1 - 0.5) squared = 0.25. Their average is 1.75 / 4 = 0.4375.

The four Y-defined balls produce squared differences 0.25, 0.25, 1, and 0.25, again averaging 0.4375. The basic unweighted empirical divergence is therefore 0.875.

This calculation is a discrepancy measure, not a p-value. With only two observations per group, it does not justify a claim of statistical significance. Testing requires an appropriate reference distribution and attention to the small sample's limitations.

Illustrative case study

Fictional case: Juniper Analytics monitors a recommendation service using customer activity and basket-size features. Two months have similar average activity, but analysts suspect that activity and spending have become associated differently.

They define a fixed scaling rule from the reference data and compare independent customer-level observations using Ball divergence. A permutation analysis indicates a distributional difference under their prespecified procedure. They then inspect feature plots and segment summaries to understand its business relevance.

The team does not immediately retrain the service. It checks collection changes, seasonal mix, and prediction quality because distributional difference alone does not establish model deterioration or identify the cause.

Common misconceptions and mistakes

Do not interpret Ball divergence as a test solely of equal means. It targets broader distributional differences.

Do not confuse Ball divergence with Ball covariance, which addresses dependence between random objects. Their related constructions answer different questions.

Do not treat a large numerical value as a universal severity score across unrelated metrics, dimensions, or weighting conventions. Likewise, a small p-value does not measure operational harm.

Do not permute labels across dependent observations without considering the design. Repeated monitoring and multiple comparisons also require a planned decision procedure rather than repeated unadjusted significance claims.

Business use

Business use is strongest when teams need an overall distribution comparison and can justify what distance means for their data. The method can complement dashboards that show individual means and quantiles, especially when changes occur in joint structure.

Adoption requires decisions about observation units, missing values, scaling, sample sizes, computational budget, and follow-up investigation. Pairwise distances and repeated permutations can become costly. A useful monitoring report separates statistical evidence, descriptive effect patterns, and measured impact on business outcomes.

People also ask

Does it require normally distributed measurements?

No; it is a nonparametric distribution-comparison approach, although it still has sampling and metric assumptions.

Can it compare more than two groups?

Implementations provide multi-sample extensions with specified aggregation rules.

Does a significant result explain which feature changed?

No. Additional descriptive or targeted analyses are needed, with their own uncertainty considerations.

Check your understanding

Why can two groups with identical means have positive population Ball divergence?

Answer: Their distributions can differ in spread, shape, or dependence despite equal means.

Is the worked example's 0.875 a probability that the distributions differ?

Answer: No. It is the calculated empirical discrepancy under the stated construction.

Related terms

  • Metric space
  • Permutation test
  • Energy distance
  • Two-sample test
  • distribution shift
  • Ball covariance
  • maximum mean discrepancy

Learn next

Learn how permutation tests obtain their validity from exchangeability. Then compare distance-based two-sample methods on the same simulated mean, variance, and dependence changes, documenting the chosen distance and testing procedure.

More in Statistics and probability

  • Backoff model - A backoff model uses a less specific model when the more specific context lacks sufficient evidence for a prediction.
  • Backward elimination - Backward elimination is a model-selection procedure that starts with a specified full set of candidate predictors and removes terms one at a time according...
  • Balanced repeated replication
  • Barnard exact test - The Barnard exact test is an unconditional exact procedure for comparing the success probabilities of two independent binomial samples, represented by a...
  • Bartlett's test - Bartlett's test is a statistical test of whether several independent normal populations have the same variance.
  • Base model - A base model is a previously trained model used as the starting point for further adaptation, especially fine-tuning for a particular task or application.

Sources

Zhu, Pan, Zheng, and Wang, Ball: An R Package for Detecting Distribution Difference and Association in Metric Spaces, author manuscript, including the empirical Ball divergence construction: https://arxiv.org/pdf/1811.03750 Ball package authors, official bd.test documentation, for test options and multi-sample extensions: https://search.r-project.org/CRAN/refmans/Ball/html/bd.test.html

Previous: Balanced repeated replication Next: Ball tree

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer