# Chen--Qin, Li, and Xue--Yao mean tests This ledger covers the pySHT-native dense and fixed-small-sample mean tests. The Xue--Yao implementation is retained privately because its requested calibration has not passed the release gate. ## Chen--Qin two-sample test For samples of sizes $n_1,n_2$, Chen and Qin (2010), Equation (2.1), define $$ T_n=\frac{\sum_{i\ne j}X_i^TX_j}{n_1(n_1-1)} +\frac{\sum_{i\ne j}Y_i^TY_j}{n_2(n_2-1)} -\frac{2\sum_{i,j}X_i^TY_j}{n_1n_2}. $$ The null variance from Equation (3.9) is $$ \widehat\sigma^2= \frac{2\widehat{\operatorname{tr}(\Sigma_1^2)}}{n_1(n_1-1)}+ \frac{2\widehat{\operatorname{tr}(\Sigma_2^2)}}{n_2(n_2-1)}+ \frac{4\widehat{\operatorname{tr}(\Sigma_1\Sigma_2)}}{n_1n_2}. $$ The implemented variance estimator is a **documented Chen--Qin variant**: its within-sample trace estimates are $A_n$ from Li and Chen (2012), Equation (2.1), and its cross-sample trace estimate is their Equation (2.2). These are not the same finite-sample quantities as the leave-two-out expression preceding Chen and Qin's Theorem 2. The result diagnostics name the variance estimator explicitly. An independent identity makes the within-sample estimator precise. If $(n)_4=n(n-1)(n-2)(n-3)$, then $$ A_n=\frac{1}{4(n)_4}\sum_{i,j,k,l\;\mathrm{distinct}} \{(X_i-X_j)^T(X_k-X_l)\}^2. $$ The two differences in each summand are independent, have mean zero and covariance $2\Sigma$, so the expected squared inner product is $4\operatorname{tr}(\Sigma^2)$. This proves unbiasedness and translation invariance without identifying the estimator with Chen--Qin's different formula. The cross-sample estimator equals $\operatorname{tr}(S_1S_2)$ and is unbiased by independence. Tests compare the Gram reductions both with literal ordered sums and with the independent pair-difference identity, and retain a fixture distinguishing $A_n=5.5303652114$ from the original leave-two-out value $5.4313033476$. The standard-normal tail is an increasing-sample-and-dimension limit, not a finite-sample exact calibration. Chen and Qin's Equations (3.1)--(3.3) assume independent samples with a linear factor representation, standardized latent coordinates that are pseudo-independent for products of distinct coordinates through total degree eight, a finite common fourth moment, and $n_1/(n_1+n_2)\to\kappa\in(0,1)$. Their Equation (3.6) additionally requires each fourth-order covariance trace to be negligible relative to $\operatorname{tr}^2\{(\Sigma_1+\Sigma_2)^2\}$. Heavy tails without the required moments, strongly spiked covariance sequences that violate the trace condition, severely unbalanced sample sizes, or small $n$ and $p$ are outside the stated null approximation. pySHT also requires at least four rows per group so the unbiased trace estimators exist and rejects a nonpositive estimated null variance instead of manufacturing a normal statistic. For this variance variant, sufficient additional conditions are Li--Chen (2012) A1--A3: both sample sizes and dimension diverge, their ratio stays away from zero and one, latent eighth moments are finite with factorized mixed moments through degree eight, and all covariance-pair traces diverge while the fourth-order traces satisfy their Equation (2.4). Section 6.3 proves the ratio consistency of each $A_n$ without needing equality of the two covariances; Section 6.5 gives the corresponding cross-trace variance bound. Consequently the positive weighted sum above is ratio consistent. Combined with Chen--Qin's null central limit theorem, Slutsky's theorem justifies this studentization. This sufficient envelope is intentionally stronger than an assumption of merely finite fourth moments; simulations alone do not establish it for arbitrary heavy-tailed data. Let $n=n_1+n_2$. The Gram reductions take $O((n_1^2+n_2^2+n_1n_2)p)=O(n^2p)$ time and $O(n^2)$ auxiliary storage. They avoid both the literal order-four loops and any dense $p\times p$ covariance matrix; input and centered-data storage remain $O(np)$. The release stream used four independently spawned PCG64 streams from `SeedSequence(20260839)`. Each shard generated 5,000 replications in order; every replication drew $X\sim N_{1000}(0,I)$ with 50 rows, then an independent $Y\sim N_{1000}(0,I)$ with 60 rows, and called `cq_2samp` once. The combined 20,000-run counts were `(259, 1030, 2045)` and rates `(0.01295, 0.05150, 0.10225)` at levels `(0.01, 0.05, 0.10)`, passing the project gate. The opt-in `tools/native_null_audits.py` runner records the exact public-call, PCG64, parent-`SeedSequence`, child-stream, draw-order, and replication contract behind this table. The targeted alternative used integer seed `20260941`, 2,000 replications, $X\sim N_{1000}(0.12\mathbf 1,I)$ with 50 rows, and $Y\sim N_{1000}(0,I)$ with 60 rows. Counts were `(2000, 2000, 2000)` and rates `(1.0000, 1.0000, 1.0000)`. Primary source: [Chen and Qin (2010)](https://doi.org/10.1214/09-AOS716), Equations (2.1), (3.9), and Theorems 1--2. Variance-estimator source: [Li and Chen (2012)](https://arxiv.org/pdf/1206.0917), Equations (2.1)--(2.2), Conditions A1--A3, and Sections 6.3 and 6.5. ## Li fixed-small-sample tests For one sample, Li (2023), Equations (2)--(4), treats $H_{ij}=X_i^TX_j$, $i