We propose two novel nonparametric two-sample kernel tests based on the Maximum Mean Discrepancy (MMD). First, for a fixed kernel, we construct an MMD test using either permutations or a wild bootstrap, two popular numerical procedures to determine the test threshold. We prove that this test controls the probability of type I error non-asymptotically. Hence, it can be used reliably even in settings with small sample sizes as it remains well-calibrated, which differs from previous MMD tests which only guarantee correct test level asymptotically. When the difference in densities lies in a Sobolev ball, we prove minimax optimality of our MMD test with a specific kernel depending on the smoothness parameter of the Sobolev ball. In practice, this parameter is unknown and, hence, the optimal MMD test with this particular kernel cannot be used. To overcome this issue, we construct an aggregated test, called MMDAgg, which is adaptive to the smoothness parameter. The test power is maximised over the collection of kernels used, without requiring held-out data for kernel selection (which results in a loss of test power), or arbitrary kernel choices such as the median heuristic. We prove that MMDAgg still controls the level non-asymptotically, and achieves the minimax rate over Sobolev balls, up to an iterated logarithmic term. Our guarantees are not restricted to a specific type of kernel, but hold for any product of one-dimensional translation invariant characteristic kernels. We provide a user-friendly parameter-free implementation of MMDAgg using an adaptive collection of bandwidths. We demonstrate that MMDAgg significantly outperforms alternative state-of-the-art MMD-based two-sample tests on synthetic data satisfying the Sobolev smoothness assumption, and that, on real-world image data, MMDAgg closely matches the power of tests leveraging the use of models such as neural networks.
翻译:我们提出两种基于最大均值差异(MMD)的新型非参数双样本核检验方法。首先,针对固定核函数,我们通过两种常用数值方法(置换检验或野自助法)确定检验阈值来构建MMD检验。我们证明该检验具有非渐近的I型错误率控制能力,因此即使在样本量较小的场景下仍能保持良好的校准性——这与现有仅保证渐近正确检验水平的MMD检验显著不同。当密度差异处于Sobolev球中时,我们证明基于特定核函数(依赖于Sobolev球光滑参数)的MMD检验具有极小极大最优性。实际应用中该参数未知,因此无法使用该特定核函数的最优MMD检验。为解决此问题,我们构建了名为MMDAgg的自适应聚合检验,可针对光滑参数实现自适应调整。该检验在所用核函数集合上最大化检验势,无需额外留出数据进行核选择(否则会导致检验势损失)或采用中位数启发式等任意核选择策略。我们证明MMDAgg仍能实现非渐近的水平控制,并在Sobolev球上达到极小极大速率(仅含迭代对数项)。我们的保证不限于特定核函数类型,而适用于任意一维平移不变特征核的乘积形式。我们提供基于自适应带宽集合的MMDAgg用户友好型无参实现。实验表明,在满足Sobolev光滑假设的合成数据上,MMDAgg显著优于现有最优的基于MMD的双样本检验;在真实图像数据上,MMDAgg的检验势能与利用神经网络等模型的检验方法相媲美。