# Two-sample Testing Using Deep Learning

arXiv: https://arxiv.org/abs/1910.06239 · HTML: https://mlsanity.com/paper/1910.06239/

## Key facts

- Cited by 27 papers in the map (data through 14 Oct 2026).
- First posted on arXiv 14 Oct 2019.

## Built on by (most cited first, 27 of 27)

- [Neural Mean Discrepancy for Efficient Out-of-Distribution Detection](https://mlsanity.com/paper/2104.11408/) (2021)
- [MMD-FUSE: Learning and Combining Kernels for Two-Sample Testing Without Data Splitting](https://mlsanity.com/paper/2306.08777/) (2023)
- [A Witness Two-Sample Test](https://mlsanity.com/paper/2102.05573/) (2021)
- [AutoML Two-Sample Test](https://mlsanity.com/paper/2206.08843/) (2022)
- [Meta Two-Sample Testing: Learning Kernels for Testing with Limited Data](https://mlsanity.com/paper/2106.07636/) (2021)
- [Compress Then Test: Powerful Kernel Testing in Near-linear Time](https://mlsanity.com/paper/2301.05974/) (2023)
- [E-Valuating Classifier Two-Sample Tests](https://mlsanity.com/paper/2210.13027/) (2022)
- [Variable Selection for Kernel Two-Sample Tests](https://mlsanity.com/paper/2302.07415/) (2023)
- [A Unified Data Representation Learning for Non-parametric Two-sample Testing](https://mlsanity.com/paper/2412.00613/) (2024)
- [Keeping Medical AI Healthy and Trustworthy: A Review of Detection and Correction Methods for System Degradation](https://mlsanity.com/paper/2506.17442/) (2025)
- [Test for non-negligible adverse shifts](https://mlsanity.com/paper/2107.02990/) (2021)
- [Statistical and Computational Guarantees of Kernel Max-Sliced Wasserstein Distances](https://mlsanity.com/paper/2405.15441/) (2024)
- [Deep Nonparametric Conditional Independence Tests for Images](https://mlsanity.com/paper/2411.06140/) (2024)
- [A fast and effective kernel two-sample test for large-scale data](https://mlsanity.com/paper/2110.03118/) (2021)
- [Adversarial Attack and Defense for Non-Parametric Two-Sample Tests](https://mlsanity.com/paper/2202.03077/) (2022)
- [Recurrent Neural Goodness-of-Fit Test for Time Series](https://mlsanity.com/paper/2410.13986/) (2024)
- [Explainability Requires Interactivity](https://mlsanity.com/paper/2109.07869/) (2021)
- [Detecting Performance Degradation under Data Shift in Pathology Vision-Language Model](https://mlsanity.com/paper/2601.00716/) (2026)
- [Drift-to-Action Controllers: Budgeted Interventions with Online Risk Certificates](https://mlsanity.com/paper/2603.08578/) (2026)
- [Two-sample test based on Self-Organizing Maps](https://mlsanity.com/paper/2212.08960/) (2022)
- [Some notes concerning a generalized KMM-type optimization method for density ratio estimation](https://mlsanity.com/paper/2309.07887/) (2023)
- [R-divergence for Estimating Model-oriented Distribution Discrepancy](https://mlsanity.com/paper/2310.01109/) (2023)
- [Machine Learning for Two-Sample Testing under Right-Censored Data: A Simulation Study](https://mlsanity.com/paper/2409.08201/) (2024)
- [Towards Visually Explaining Statistical Tests with Applications in Biomedical Imaging](https://mlsanity.com/paper/2601.13899/) (2026)
- [Learning to Test: Latent Representation Learning for Dynamic Instability Detection](https://mlsanity.com/paper/2604.10967/) (2026)
- [Counterfactual Explanations for Deep Two-Sample Testing](https://mlsanity.com/paper/2606.04009/) (2026)
- [Two-Sample Testing for Random Graphs without Vertex Correspondence](https://mlsanity.com/paper/2610.07503/) (2026)

## Abstract (arXiv)

We propose a two-sample testing procedure based on learned deep neural network representations. To this end, we define two test statistics that perform an asymptotic location test on data samples mapped onto a hidden layer. The tests are consistent and asymptotically control the type-1 error rate. Their test statistics can be evaluated in linear time (in the sample size). Suitable data representations are obtained in a data-driven way, by solving a supervised or unsupervised transfer-learning task on an auxiliary (potentially distinct) data set. If no auxiliary data is available, we split the data into two chunks: one for learning representations and one for computing the test statistic. In experiments on audio samples, natural images and three-dimensional neuroimaging data our tests yield significant decreases in type-2 error rate (up to 35 percentage points) compared to state-of-the-art two-sample tests such as kernel-methods and classifier two-sample tests.
