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检验,这两种主流的数值程序用于确定检验阈值。我们证明该检验能非渐近地控制第一类错误概率。因此,即使在样本量较小的场景中,该检验也能保持良好校准性且可可靠使用,这与仅能渐近保证检验水平的传统MMD检验不同。当密度差异位于Sobolev球中时,我们证明基于特定核函数(取决于Sobolev球的光滑参数)的MMD检验具有极小极大最优性。实践中该参数未知,因此无法使用该特定核函数的最优MMD检验。为解决此问题,我们构建了一种称为MMDAgg的自适应聚合检验方法,可自适应光滑参数。该检验通过对所使用的核函数集合进行最大化检验功效,无需保留数据进行核选择(这会导致检验功效损失)或采用中位数启发式等任意核选择策略。我们证明MMDAgg仍能非渐近地控制检验水平,并达到Sobolev球上的极小极大速率(仅相差一个迭代对数项)。我们的保证不局限于特定核函数类型,而适用于任意一维平移不变特征核的乘积形式。我们通过自适应带宽集合提供了用户友好的无参数化MMDAgg实现方案。实验表明,在满足Sobolev平滑假设的合成数据中,MMDAgg显著优于其他基于MMD的现有双样本检验方法;而在真实图像数据中,MMDAgg的检验功效与利用神经网络等模型的检验方法高度接近。