Abstract
Computing higher-order $U$-statistics has traditionally been a computational bottleneck in statistics and machine learning, characterized by an $O(n^m)$ complexity that renders exact calculations impossible for large datasets or high orders. This paper introduces a novel framework that decomposes $U$-statistics into $V$-statistics, enabling the use of Einstein summation (Einsum) and hardware acceleration. By leveraging the structural properties of kernels—specifically their treewidth—and a novel sparsification technique, the proposed method reduces runtimes from hours to seconds. The authors provide an open-source Python package, u-stats, which demonstrates significant speedups across applications in causal inference, network analysis, and independence testing.
Introduction
In modern statistical analysis, $U$-statistics serve as a foundational tool for estimating parameters such as variance, covariance, and higher-order moments. An $m$-th order $U$-statistic is defined as the average of a kernel function applied to all possible subsets of size $m$ from a dataset of size $n$. While they possess desirable statistical properties like unbiasedness and asymptotic normality, their computational cost is $O(n^m)$.
For instance, calculating a 7th-order $U$-statistic on a dataset of $n=10,000$ requires approximately $10^{28}$ operations. To circumvent this "curse of dimensionality," researchers often rely on "incomplete" $U$-statistics, which sample only a fraction of the possible permutations. However, this introduces sampling variance and potential inconsistency. This paper presents a framework for the exact computation of higher-order $U$-statistics, making them practical for real-world applications for the first time.
Methodology
1. U-to-V Decomposition
The core of the proposed approach is the realization that $U$-statistics can be represented as a linear combination of $V$-statistics. Unlike $U$-statistics, $V$-statistics allow for repeated indices (sampling with replacement). While $U$-statistics are the standard in statistical theory, $V$-statistics are the natural language of tensor contractions, which can be optimized using modern computational libraries.
2. Multiplicative-Decomposable (MD) Kernels
The framework focuses on Multiplicative-Decomposable (MD) kernels. These are kernels that can be factored into smaller, simpler components. This structure is prevalent in many advanced statistical methods, including Higher-Order Influence Functions (HOIF) used in causal inference.
3. Tensorization and Einstein Summation
By treating data as tensors, the authors map the calculation of $V$-statistics to the Einstein summation (Einsum) operation. This allows the algorithm to leverage highly optimized backends like NumPy and PyTorch. Crucially, this enables the use of GPUs, which are specifically designed for the massive parallelization required for tensor contractions.
4. Structural Complexity and Treewidth
The authors demonstrate that the computational difficulty of a $U$-statistic is not solely determined by its order $m$, but by its internal connectivity. By associating a "decomposition graph" with the kernel, they show that the complexity is governed by the graph's treewidth. A kernel with a low treewidth (e.g., a "chain" structure) can be computed much faster than a fully connected kernel of the same order.
5. The Sparsification Trick
A naive $U$-to-$V$ decomposition involves a number of terms that grows super-exponentially (following the Bell number). The authors introduce a "sparsification trick" that identifies and skips terms guaranteed to be zero. This keeps the number of required Einsum operations manageable even as the order $m$ increases.
Experimental Results
The framework was implemented in the u-stats Python package and tested across three distinct domains:
- Higher-Order Influence Functions (HOIF): On synthetic datasets with $n=10,000$ and $m=12$, the package achieved massive speedups. A 7th-order HOIF calculation that took 5 minutes on a CPU was completed in just 12 seconds on an NVIDIA RTX 4090 GPU.
- Motif Counting: In network analysis, counting subgraphs (motifs) is a classic $U$-statistic problem.
u-statsoutperformed the specializedigraphpackage by over 2,900x when counting 3-vertex motifs in dense Erdös-Rényi graphs. - Distance Covariance ($dCov^2$): When testing for independence in S&P 500 stock data, the exact parallel implementation in
u-statstook 0.18 seconds, compared to nearly one hour (3,395 seconds) for a standard MATLAB implementation.
Discussion and Limitations
While the framework provides a breakthrough in time complexity, it introduces a trade-off in space complexity. Storing high-order tensors requires significant memory (RAM/VRAM), which places an upper bound on the sample size $n$ for extremely high-order kernels. Additionally, the current implementation is optimized for scalar-valued statistics, with vector- and matrix-valued extensions planned for future work.
Conclusion
This work transforms higher-order $U$-statistics from a theoretical ideal into a practical tool. By combining graph theory, tensor algebra, and modern hardware acceleration, the u-stats framework allows researchers to compute exact statistics in seconds that previously required hours or were computationally impossible. This opens new avenues for rigorous statistical inference in high-dimensional settings.
Summary updated