SlowGuess/NeurIPS_2023_OCR huggingface dataset:
$$
\begin{array}{l} \frac {1}{N ^ {2}} \left\langle \mathbf {K} \circ \mathbf {K} \circ \mathbf {L} - 4 \mathbf {K} \circ \mathbf {K H} \circ \mathbf {L} - 2 \mathbf {K} \circ \mathbf {K} \circ \mathbf {L H} \right. \\ + 4 \mathbf {K} \mathbf {H} \circ \mathbf {K} \circ \mathbf {L} \mathbf {H} + 2 \mathbf {K} \circ \mathbf {L} \left\langle \frac {\mathbf {K}}{N ^ {2}} \right\rangle + 2 \mathbf {K} \mathbf {H} \circ \mathbf {H} \mathbf {K} \circ \mathbf {L} \\ + 4 \mathbf {K} \circ \mathbf {H K} \circ \mathbf {L H} + \mathbf {K} \circ \mathbf {K} \left\langle \frac {\mathbf {L}}{N ^ {2}} \right\rangle - 8 \mathbf {K} \circ \mathbf {L H} \left\langle \frac {\mathbf {K}}{N ^ {2}} \right\rangle \\ - 4 \mathbf {K} \circ \mathbf {H K} \left\langle \frac {\mathbf {L}}{N ^ {2}} \right\rangle + 4 \left\langle \frac {\mathbf {K}}{N ^ {2}} \right\rangle^ {2} \mathbf {L} \Bigg >. \\ \end{array}
$$
Again this estimator can be computed in quadratic time.
Example E.3 (Estimating  $\| \kappa_k^{(3)}(\gamma) - \kappa_k^{(3)}(\eta)\|_{\mathcal{H}_k^{\otimes 3}}^2$ ). In order to estimate  $d^{(3)}(\gamma ,\eta)$  we note that one can write
$$
\begin{array}{l} \| \kappa_ {k} ^ {(3)} (\gamma) - \kappa_ {k} ^ {(3)} (\eta) \| _ {\mathcal {H} _ {k} ^ {\otimes 3}} ^ {2} = \| \kappa_ {k} ^ {(3)} (\gamma) \| _ {\mathcal {H} _ {k} ^ {\otimes 3}} ^ {2} + \| \kappa_ {k} ^ {(3)} (\eta) \| _ {\mathcal {H} _ {k} ^ {\otimes 3}} ^ {2} \\ - 2 \langle \kappa_ {k} ^ {(3)} (\gamma), \kappa_ {k} ^ {(3)} (\eta) \rangle_ {\mathcal {H} _ {k} ^ {\otimes 3}}. \\ \end{array}
$$
We can estimate the first two terms like in Example E.2, and the third term can be expressed as
$$
\begin{array}{l} \langle \kappa_ {k} ^ {(3)} (\gamma), \kappa_ {k} ^ {(3)} (\eta) \rangle_ {\mathcal {H} _ {k} ^ {\otimes 3}} = \mathbb {E} k (X, Y) ^ {3} - 3 \mathbb {E} k (X, Y) ^ {2} k (X, Y ^ {\prime}) ^ {2} \\ - 3 \mathbb {E} k (X, Y) ^ {2} k \left(X ^ {\prime}, Y\right) ^ {2} + 6 \mathbb {E} k (X, Y) k \left(X, Y ^ {\prime}\right) k \left(X ^ {\prime}, Y\right) \\ + 3 \mathbb {E} k (X, Y) ^ {2} k \left(X ^ {\prime}, Y ^ {\prime}\right) + 2 \mathbb {E} k (X, Y) k \left(X ^ {\prime}, Y\right) k \left(X ^ {\prime \prime}, Y\right) \\ + 2 \mathbb {E} k (X, Y) k (X, Y ^ {\prime}) k (X, Y ^ {\prime \prime}) - 6 \mathbb {E} k (X, Y) k (X, Y ^ {\prime}) k (X ^ {\prime}, Y ^ {\prime \prime}) \\ - 6 \mathbb {E} k (X, Y) k (X ^ {\prime}, Y) k (X ^ {\prime \prime}, Y ^ {\prime}) + 4 \mathbb {E} k (X, Y) k (X ^ {\prime}, Y ^ {\prime}) k (X ^ {\prime \prime}, Y ^ {\prime \prime}). \\ \end{array}
$$
For simplicity we will assume that we have an equal number of samples  $(N)$  from both measures  $(x_{i})_{i = 1}^{N}\in \gamma$  and  $(y_{i})_{i = 1}^{N}\in \eta$ . The V-statistic for  $\langle \kappa_k^{(3)}(\gamma),\kappa_k^{(3)}(\eta)\rangle_{\mathcal{H}_k^{\otimes 3}}$  can be expressed as
$$
\begin{array}{l} \frac {1}{N ^ {2}} \sum_ {i, j = 1} ^ {N} k (x _ {i}, y _ {j}) ^ {3} - \frac {3}{N ^ {3}} \sum_ {i, j, \kappa = 1} ^ {N} k (x _ {i}, y _ {j}) ^ {2} k (x _ {i}, y _ {\kappa}) \\ - \frac {3}{N ^ {3}} \sum_ {i, j, \kappa = 1} ^ {N} k (x _ {i}, y _ {j}) ^ {2} k (x _ {\kappa}, y _ {i}) + \frac {6}{N ^ {4}} \sum_ {i, j, \kappa , l = 1} ^ {N} k (x _ {i}, y _ {j}) k (x _ {i}, y _ {\kappa}) k (x _ {l}, y _ {j}) \\ + \frac {3}{N ^ {4}} \sum_ {i, j, \kappa , l = 1} ^ {N} k (x _ {i}, y _ {j}) ^ {2} k (x _ {\kappa}, y _ {l}) + \frac {2}{N ^ {4}} \sum_ {i, j, \kappa , l = 1} ^ {N} k (x _ {i}, y _ {j}) k (x _ {\kappa}, y _ {j}) k (x _ {l}, y _ {j}) \\ + \frac {2}{N ^ {4}} \sum_ {i, j, \kappa , l = 1} ^ {N} k (x _ {i}, y _ {j}) k (x _ {i}, y _ {\kappa}) k (x _ {i}, y _ {l}) - \frac {6}{N ^ {5}} \sum_ {i, j, \kappa , l, m = 1} ^ {N} k (x _ {i}, y _ {j}) k (x _ {i}, y _ {\kappa}) k (x _ {l}, y _ {m}) \\ - \frac {6}{N ^ {5}} \sum_ {i, j, \kappa , l, m = 1} ^ {N} k (x _ {i}, y _ {j}) k (x _ {\kappa}, y _ {j}) k (x _ {l}, y _ {m}) + \frac {4}{N ^ {6}} \sum_ {i, j, \kappa , l, m, n = 1} ^ {N} k (x _ {i}, y _ {j}) k (x _ {\kappa}, y _ {l}) k (x _ {m}, y _ {n}). \\ \end{array}
$$
Using the notation  $\mathbf{K}_{xy} = [k(x_i,y_j)]_{i,j = 1}^N$ , this estimator simplifies to
$$
\begin{array}{l} \frac {1}{N ^ {2}} \left\langle \mathbf {K} _ {x y} \circ \mathbf {K} _ {x y} \circ \mathbf {K} _ {x y} - 3 \mathbf {K} _ {x y} \circ \mathbf {K} _ {x y} \circ \mathbf {H K} _ {x y} \right. \\ - 3 \mathbf {K} _ {x y} \circ \mathbf {K} _ {x y} \circ \mathbf {K} _ {x y} \mathbf {H} + 6 \mathbf {K} _ {x y} \circ \mathbf {K} _ {x y} \mathbf {H} \circ \mathbf {H} \mathbf {K} _ {x y} \\ + 3 \mathbf {K} _ {x y} \circ \mathbf {K} _ {x y} \left\langle \frac {\mathbf {K} _ {x y}}{N ^ {2}} \right\rangle + 2 \mathbf {K} _ {x y} \circ \mathbf {H K} _ {x y} \circ \mathbf {H K} _ {x y} \\ + 2 \mathbf {K} _ {x y} \circ \mathbf {K} _ {x y} \mathbf {H} \circ \mathbf {K} _ {x y} \mathbf {H} - 6 \mathbf {K} _ {x y} \circ \mathbf {K} _ {x y} \mathbf {H} \left\langle \frac {\mathbf {K} _ {x y}}{N ^ {2}} \right\rangle \\ - 6 \mathbf {K} _ {x y} \circ \mathbf {H K} _ {x y} \left\langle \frac {\mathbf {K} _ {x y}}{N ^ {2}} \right\rangle + 4 \left\langle \frac {\mathbf {K}}{N ^ {2}} \right\rangle^ {2} \mathbf {K} _ {x y} \Bigg >. \\ \end{array}
$$
We mention also that the first two terms  $\| \kappa_k^{(3)}(\gamma)\|_{\mathcal{H}_k^{\otimes 3}}^2,\| \kappa_k^{(3)}(\eta)\|_{\mathcal{H}_k^{\otimes 3}}^2$  can be computed a little more simply than in Example E.2 since the expressions have more symmetry, using the notation  $\mathbf{K}_x = [k(x_i,x_j)]_{i,j = 1}^N$  we can write down the V-statistic for  $\| \kappa_k^{(3)}(\gamma)\|_{\mathcal{H}_k^{\otimes 3}}^2$  as
$$
\begin{array}{l} \frac {1}{N ^ {2}} \left\langle \mathbf {K} _ {x} \circ \mathbf {K} _ {x} \circ \mathbf {K} _ {x} - 6 \mathbf {K} _ {x} \circ \mathbf {K} _ {x} \mathbf {H} \circ \mathbf {K} _ {x} \right. \\ + 4 \mathbf {K} _ {x} \mathbf {H} \circ \mathbf {K} _ {x} \circ \mathbf {K} _ {x} \mathbf {H} + 3 \mathbf {K} _ {x} \circ \mathbf {K} _ {x} \left\langle \frac {\mathbf {K} _ {x}}{N ^ {2}} \right\rangle \\ + 6 \mathbf {K} _ {x} \mathbf {H} \circ \mathbf {H} \mathbf {K} _ {x} \circ \mathbf {K} _ {x} - 1 2 \mathbf {K} _ {x} \circ \mathbf {H} \mathbf {K} _ {x} \left\langle \frac {\mathbf {K} _ {x}}{N ^ {2}} \right\rangle \\ + 4 \left\langle \frac {\mathbf {K} _ {x}}{N ^ {2}} \right\rangle^ {2} \mathbf {K} _ {x} \Bigg \rangle \\ \end{array}
$$
with a similar expression for  $\| \kappa_k^{(3)}(\eta)\|_{\mathcal{H}_k^{\otimes 3}}^2$ . The estimator can be computed in quadratic time.