SlowGuess/NeurIPS_2023_OCR huggingface dataset:
$$
\begin{array}{l} \operatorname * {P r} [ h = 1 \mid \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \geq 0 ] = \operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , \beta \alpha} ^ {2} \mid \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \geq 0 \right] \\ > \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {z} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {z} \geq \chi_ {\ell , \beta \alpha} ^ {2} \right], \tag {17} \\ \end{array}
$$
by substituting  $c = \chi_{\ell, \beta \alpha}^2$  into Eqn. (14). From  $\pmb{\mu}_{\hat{\mathbb{P}}} \neq \pmb{\mu}_{\hat{\mathbb{Q}}}$ , we also have, from the work of [84],
$$
\frac {m ^ {\prime} + n ^ {\prime} - \ell - 1}{(m ^ {\prime} + n ^ {\prime} - 2) \ell} \mathcal {T} (\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}) = \frac {m ^ {\prime} + n ^ {\prime} - \ell - 1}{(m ^ {\prime} + n ^ {\prime} - 2) \ell} \times \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {z} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {z} \sim F (\ell , m ^ {\prime} + n ^ {\prime} - 1 - \ell , \lambda),
$$
where  $\lambda = m'n'(\pmb{\mu}_{\hat{\mathbb{P}}} - \pmb{\mu}_{\hat{\mathbb{Q}}})^{\top}\Sigma_{\hat{\mathbb{P}},\hat{\mathbb{Q}}}^{-1}(\pmb{\mu}_{\hat{\mathbb{P}}} - \pmb{\mu}_{\hat{\mathbb{Q}}}) / (m' + n')$ . Given the significance level  $\beta \alpha$ , we have
$$
\Pr \left[ \frac {m ^ {\prime} + n ^ {\prime} - \ell - 1}{(m ^ {\prime} + n ^ {\prime} - 2) \ell} \mathcal {T} \left(\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}\right) \geq F _ {\ell , m ^ {\prime} + n ^ {\prime} - 1 - \ell , \beta \alpha} \right] = q (\ell , m ^ {\prime} + n ^ {\prime} - 1 - \ell , \lambda , \beta \alpha), \tag {18}
$$
$$
\Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , \beta \alpha} ^ {2} \right] = q (\ell , m ^ {\prime} + n ^ {\prime} - 1 - \ell , \lambda , \beta \alpha).
$$
Recall  $\pmb{B} = \sqrt{m'n' / (m' + n')} \pmb{L}'^{-1} \mathrm{diag}(\pmb{F}) \bar{\pmb{z}}$  and  $\pmb{F}^{\top} \pmb{L}'^{-1} \bar{\pmb{z}} = \sqrt{(m' + n') / m'n'} \pmb{1}^{\top} \pmb{B}$  in the proof of Lemma 3, and that  $\bar{B} = \mathbf{1}^{\top} \pmb{B} / \ell$  is normally distributed with mean  $\sqrt{m'n' / (m' + n')} \pmb{F}^{\top} \pmb{L}_{\hat{\mathbb{P}},\hat{\mathbb{Q}}}^{-1} (\pmb{\mu}_{\hat{\mathbb{P}}} - \pmb{\mu}_{\hat{\mathbb{Q}}}) / \ell$  and variance  $1 / \ell$ . We have
$$
\Pr \left[ \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {z} > 0 \right] = \Pr [ \bar {B} \geq 0 ] = 1 - \Phi \left(- \sqrt {\frac {m ^ {\prime} n ^ {\prime}}{\left(m ^ {\prime} + n ^ {\prime}\right) \ell}} \boldsymbol {F} ^ {\top} \boldsymbol {L} _ {\hat {\mathbb {P}}, \hat {\mathbb {Q}}} ^ {- 1} \left(\boldsymbol {\mu} _ {\hat {\mathbb {P}}} - \boldsymbol {\mu} _ {\hat {\mathbb {Q}}}\right)\right), \tag {19}
$$
since  $\bar{B}$  is normally distributed with mean  $\sqrt{m'n' / (m' + n')} \pmb{F}^{\top} \pmb{L}_{\hat{\mathbb{P}},\hat{\mathbb{Q}}}^{-1} (\pmb{\mu}_{\hat{\mathbb{P}}} - \pmb{\mu}_{\hat{\mathbb{Q}}}) / \ell$  and variance  $1 / \ell$ . Combining with Eqns. (17)-(19), we have
$$
\begin{array}{l} \operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\pmb {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\pmb {z}} \geq \chi_ {\ell , \beta \alpha} ^ {2} \cap \pmb {F} ^ {\top} \pmb {L} ^ {\prime - 1} \bar {\pmb {z}} \geq 0 \right] \\ = \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , \beta \alpha} ^ {2} \mid \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \geq 0 \right] \Pr [ \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \geq 0 ] \\ > \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {z} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {z} \geq \chi_ {\ell , \beta \alpha} ^ {2} \right] \Pr [ \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {z} \geq 0 ] \\ = q \left(\ell , m ^ {\prime} + n ^ {\prime} - 1 - \ell , \lambda , \beta \alpha\right) \left(1 - \Phi \left(- \sqrt {\frac {m ^ {\prime} n ^ {\prime}}{\left(m ^ {\prime} + n ^ {\prime}\right) \ell}} \boldsymbol {F} ^ {\top} \boldsymbol {L} _ {\hat {\mathbb {P}}, \hat {\mathbb {Q}}} ^ {- 1} \left(\boldsymbol {\mu} _ {\hat {\mathbb {P}}} - \boldsymbol {\mu} _ {\hat {\mathbb {Q}}}\right)\right)\right). \tag {20} \\ \end{array}
$$
For  $\pmb{F}^{\top}\pmb{L}_{\hat{\mathbb{P}},\hat{\mathbb{Q}}}^{-1}\pmb{\mu}_{\hat{\mathbb{P}}} > \pmb{F}^{\top}\pmb{L}_{\hat{\mathbb{P}},\hat{\mathbb{Q}}}^{-1}\pmb{\mu}_{\hat{\mathbb{Q}}}$ , we substitute  $c = \chi_{\ell,(2-\beta)\alpha}^{2}$  into Eqn. (14), and it holds that
$$
\begin{array}{l} \operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\pmb {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\pmb {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \cap \pmb {F} ^ {\top} \pmb {L} ^ {\prime - 1} \bar {\pmb {z}} <   0 \right] \\ = \Pr \left[ \bar {B} ^ {2} \geq \left(\chi_ {\ell , (2 - \beta) \alpha} ^ {2} - S ^ {2}\right) / \ell \cap \bar {B} <   0 \right] \\ = \operatorname * {P r} \left[ \bar {B} \leq - \sqrt {\left(\chi_ {\ell , (2 - \beta) \alpha} ^ {2} - S ^ {2}\right) / \ell} \right] \\ { = } { \Phi \left[ - \sqrt { \chi _ { \ell , ( 2 - \beta ) \alpha } ^ { 2 } - S ^ { 2 } } - \sqrt { \frac { m ^ { \prime } n ^ { \prime } } { ( m ^ { \prime } + n ^ { \prime } ) \ell } } \pmb { F } ^ { \top } \pmb { L } _ { \hat { \mathbb { P } } , \hat { \mathbb { Q } } } ^ { - 1 } ( \pmb { \mu } _ { \hat { \mathbb { P } } } - \pmb { \mu } _ { \hat { \mathbb { Q } } } ) \right] } \\ > \quad \Phi \left[ - \sqrt {\chi_ {\ell , (2 - \beta) \alpha} ^ {2}} - \sqrt {\frac {m ^ {\prime} n ^ {\prime}}{(m ^ {\prime} + n ^ {\prime}) \ell}} \boldsymbol {F} ^ {\top} \boldsymbol {L} _ {\hat {\mathbb {P}}, \hat {\mathbb {Q}}} ^ {- 1} \left(\boldsymbol {\mu} _ {\hat {\mathbb {P}}} - \boldsymbol {\mu} _ {\hat {\mathbb {Q}}}\right) \right]. \tag {21} \\ \end{array}
$$
Combining with Eqns. (20)-(21), we give a lower bound for the test power of bi-directional hypothesis
$$
\begin{array}{l} \Pr [ h = 1 ] = \Pr [ h = 1 \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} > 0 ] + \Pr [ h = 1 \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} <   0 ] \\ = \operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , \beta \alpha} ^ {2} \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \geq 0 \right] \\ + \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} <   0 \right] \\ > q (\ell , m ^ {\prime} + n ^ {\prime} - 1 - \ell , \lambda , \beta \alpha) \left(1 - \Phi (- \sqrt {\frac {m ^ {\prime} n ^ {\prime}}{(m ^ {\prime} + n ^ {\prime}) \ell}} \boldsymbol {F} ^ {\top} \boldsymbol {L} _ {\mathbb {P}, \hat {\mathbb {Q}}} ^ {- 1} (\boldsymbol {\mu} _ {\mathbb {P}} - \boldsymbol {\mu} _ {\hat {\mathbb {Q}}}))\right) \\ + \Phi \left(- \sqrt {\chi_ {\ell , (2 - \beta) \alpha} ^ {2}} - \sqrt {\frac {m ^ {\prime} n ^ {\prime}}{(m ^ {\prime} + n ^ {\prime}) \ell}} \boldsymbol {F} ^ {\top} \boldsymbol {L} _ {\mathbb {P}, \hat {\mathbb {Q}}} ^ {- 1} (\boldsymbol {\mu} _ {\mathbb {P}} - \boldsymbol {\mu} _ {\hat {\mathbb {Q}}})\right). \\ \end{array}
$$
Lemma 15. If  $\pmb{F}^{\top}\pmb{L}_{\mathbb{P},\hat{\mathbb{Q}}}^{-1}\pmb{\mu}_{\hat{\mathbb{P}}} < \pmb{F}^{\top}\pmb{L}_{\mathbb{P},\hat{\mathbb{Q}}}^{-1}\pmb{\mu}_{\hat{\mathbb{Q}}},$  then the test power of our bi-directional hypothesis can be lower bounded by
$$
q (\ell , \nu - \ell , \lambda , (2 - \beta) \alpha) (1 - \xi) + 1 - \Phi \left((\chi_ {\ell , \beta \alpha} ^ {2}) ^ {1 / 2} - (\omega / \ell) ^ {1 / 2} \pmb {F} ^ {\top} \pmb {L} _ {\hat {\mathbb {P}}, \hat {\mathbb {Q}}} ^ {- 1} (\pmb {\mu} _ {\hat {\mathbb {P}}} - \pmb {\mu} _ {\hat {\mathbb {Q}}})\right),
$$
Proof. From Corollary 13, we have, for  $F^{\top}L_{\hat{\mathbb{P}},\hat{\mathbb{Q}}}^{-1}\pmb{\mu}_{\hat{\mathbb{P}}} < F^{\top}L_{\hat{\mathbb{P}},\hat{\mathbb{Q}}}^{-1}\pmb{\mu}_{\hat{\mathbb{Q}}}$ ,
$$
\begin{array}{l} \Pr \left[ h = 1 \mid \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \leq 0 \right] = \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \mid \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} <   0 \right] \\ > \mathrm {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \right], \\ \end{array}
$$
$$
\operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \right] = q (\ell , m ^ {\prime} + n ^ {\prime} - 1 - \ell , \lambda , (2 - \beta) \alpha)
$$
in the proof of Lemma 14, and this follows that
$$
\begin{array}{l} \operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\pmb {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\pmb {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \cap \pmb {F} ^ {\top} \pmb {L} ^ {\prime - 1} \bar {\pmb {z}} <   0 \right] \\ = \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {z} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {z} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \mid F ^ {\top} L ^ {\prime - 1} \bar {z} <   0 \right] \Pr [ F ^ {\top} L ^ {\prime - 1} \bar {z} <   0 ] \\ > \operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \right] \operatorname * {P r} [ \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} <   0 ] \\ = q \left(\ell , m ^ {\prime} + n ^ {\prime} - 1 - \ell , \lambda , (2 - \beta) \alpha\right) \Phi \left(- \sqrt {\frac {m ^ {\prime} n ^ {\prime}}{\left(m ^ {\prime} + n ^ {\prime}\right) \ell}} \boldsymbol {F} ^ {\top} \boldsymbol {L} _ {\hat {\mathbb {P}}, \hat {\mathbb {Q}}} ^ {- 1} \left(\boldsymbol {\mu} _ {\hat {\mathbb {P}}} - \boldsymbol {\mu} _ {\hat {\mathbb {Q}}}\right)\right). \tag {22} \\ \end{array}
$$
Recall  $\pmb{B} = \sqrt{m'n' / (m' + n')} \pmb{L}'^{-1} \mathrm{diag}(\pmb{F}) \bar{z}$  and  $\pmb{F}^{\top} \pmb{L}'^{-1} \bar{z} = \sqrt{(m' + n') / m'n'} \pmb{1}^{\top} \pmb{B}$  in the proof of Lemma 3, and that  $\bar{B} = \mathbf{1}^{\top} \pmb{B} / \ell$  is normally distributed with mean  $\sqrt{m'n' / (m' + n')} \pmb{F}^{\top} \pmb{L}_{\hat{\mathbb{P}},\hat{\mathbb{Q}}}^{-1} (\pmb{\mu}_{\hat{\mathbb{P}}} - \pmb{\mu}_{\hat{\mathbb{Q}}}) / \ell$  and variance  $1 / \ell$ . We have, if  $\pmb{F}^{\top} \pmb{L}_{\hat{\mathbb{P}},\hat{\mathbb{Q}}}^{-1} \pmb{\mu}_{\hat{\mathbb{P}}} < \pmb{F}^{\top} \pmb{L}_{\hat{\mathbb{P}},\hat{\mathbb{Q}}}^{-1} \pmb{\mu}_{\hat{\mathbb{Q}}},$
$$
\begin{array}{l} \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , \beta \alpha} ^ {2} \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \geq 0 \right] \\ = \Pr \left[ \bar {B} ^ {2} \geq \left(\chi_ {\ell , \beta \alpha} ^ {2} - S ^ {2}\right) / \ell \cap \bar {B} \geq 0 \right] \\ = \operatorname * {P r} \left[ \bar {B} \geq \sqrt {\left(\chi_ {\ell , \beta \alpha} ^ {2} - S ^ {2}\right) / \ell} \right] \\ = 1 - \Phi \left(\sqrt {\chi_ {\ell , \beta \alpha} ^ {2} - S ^ {2}} - \sqrt {\frac {m ^ {\prime} n ^ {\prime}}{(m ^ {\prime} + n ^ {\prime}) \ell}} \boldsymbol {F} ^ {\top} \boldsymbol {L} _ {\hat {\mathbb {P}}, \hat {\mathbb {Q}}} ^ {- 1} (\boldsymbol {\mu} _ {\hat {\mathbb {P}}} - \boldsymbol {\mu} _ {\hat {\mathbb {Q}}})\right) \\ > 1 - \Phi \left(\sqrt {\chi_ {\ell , \beta \alpha} ^ {2}} - \sqrt {\frac {m ^ {\prime} n ^ {\prime}}{(m ^ {\prime} + n ^ {\prime}) \ell}} \boldsymbol {F} ^ {\top} \boldsymbol {L} _ {\mathbb {P}, \hat {\mathbb {Q}}} ^ {- 1} \left(\boldsymbol {\mu} _ {\mathbb {P}} - \boldsymbol {\mu} _ {\hat {\mathbb {Q}}}\right)\right). \tag {23} \\ \end{array}
$$
Combining with Eqns. (22)-(23), we give a lower bound for the test power of bi-directional hypothesis
$$
\begin{array}{l} \Pr [ h = 1 ] = \Pr [ h = 1 \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \geq 0 ] + \Pr [ h = 1 \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} <   0 ] \\ { = } { \operatorname * { P r } \left[ \frac { m ^ { \prime } n ^ { \prime } } { m ^ { \prime } + n ^ { \prime } } \bar { \pmb { z } } ^ { \top } \Sigma _ { \hat { X } ^ { \prime } , \hat { Y } ^ { \prime } } ^ { - 1 } \bar { \pmb { z } } \geq \chi _ { \ell , \beta \alpha } ^ { 2 } \cap \pmb { F } ^ { \top } \pmb { L } ^ { \prime - 1 } \bar { \pmb { z } } \geq 0 \right] } \\ + \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} <   0 \right] \\ > q (\ell , m ^ {\prime} + n ^ {\prime} - 1 - \ell , \lambda , (2 - \beta) \alpha) \Phi \left(- \sqrt {\frac {m ^ {\prime} n ^ {\prime}}{(m ^ {\prime} + n ^ {\prime}) \ell}} \boldsymbol {F} ^ {\top} \boldsymbol {L} _ {\hat {\mathbb {P}}, \hat {\mathbb {Q}}} ^ {- 1} (\boldsymbol {\mu} _ {\hat {\mathbb {P}}} - \boldsymbol {\mu} _ {\hat {\mathbb {Q}}})\right) \\ + 1 - \Phi \left(\sqrt {\chi_ {\ell , \beta \alpha} ^ {2}} - \sqrt {\frac {m ^ {\prime} n ^ {\prime}}{(m ^ {\prime} + n ^ {\prime}) \ell}} \boldsymbol {F} ^ {\top} \boldsymbol {L} _ {\hat {\mathbb {P}}, \hat {\mathbb {Q}}} ^ {- 1} (\boldsymbol {\mu} _ {\hat {\mathbb {P}}} - \boldsymbol {\mu} _ {\hat {\mathbb {Q}}})\right). \\ \end{array}
$$
Lemma 16. For our bi-directional hypothesis, the type-I error rate is equal to  $\alpha$  if  $\pmb{\mu}_{\hat{\mathbb{P}}} = \pmb{\mu}_{\hat{\mathbb{Q}}}$ .
Proof. We first consider the case  $F^{\top}L'^{-1}\bar{z} > 0$ . By substituting  $c = \chi_{\ell, \beta \alpha}^{2}$  into Eqn. (14), we have
$$
\begin{array}{l} \Pr [ h = 1 | \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {z} \geq 0 ] \\ = \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , \beta \alpha} ^ {2} \mid \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \geq 0 \right] \\ = \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , \beta \alpha} ^ {2} \right] \\ = \beta \alpha . \\ \end{array}
$$
$$
\Pr \left[ \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \tilde {\boldsymbol {z}} \geq 0 \right] = \Pr \left[ \bar {B} \geq 0 \right] = 1 / 2,
$$
$$
\begin{array}{l} P \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , \beta \alpha} ^ {2} \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \geq 0 \right] \\ = \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {z} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {z} \geq \chi_ {\ell , \beta \alpha} ^ {2} \mid F ^ {\top} L ^ {\prime - 1} \bar {z} \geq 0 \right] \Pr [ F ^ {\top} L ^ {\prime - 1} \bar {z} \geq 0 ] = \frac {\beta \alpha}{2}, \tag {24} \\ \end{array}
$$
since  $\bar{B}$  is normally distributed with mean 0.
For the case  $F^{\top}L^{\prime -1}\bar{z} < 0$ , we similarly substitute  $c = \chi_{\ell ,(2 - \beta)\alpha}^{2}$  into Eqn. (14), and it follows that
$$
\begin{array}{l} \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} <   0 \right] \\ { = } { \operatorname * { P r } \left[ \frac { m ^ { \prime } n ^ { \prime } } { m ^ { \prime } + n ^ { \prime } } \bar { \boldsymbol { z } } ^ { \top } \Sigma _ { \hat { X } ^ { \prime } , \hat { Y } ^ { \prime } } ^ { - 1 } \bar { \boldsymbol { z } } \geq \chi _ { \ell , ( 2 - \beta ) \alpha } ^ { 2 } \right] } \\ - \operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\pmb {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\pmb {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \cap \pmb {F} ^ {\top} \pmb {L} ^ {\prime - 1} \bar {\pmb {z}} \geq 0 \right] \\ = \operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \right] \\ - \operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\boldsymbol {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\boldsymbol {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \right] \operatorname * {P r} [ \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} \geq 0 ] \\ { = } { \operatorname * { P r } \left[ \frac { m ^ { \prime } n ^ { \prime } } { m ^ { \prime } + n ^ { \prime } } \bar { z } ^ { \top } \Sigma _ { \hat { X } ^ { \prime } , \hat { Y } ^ { \prime } } ^ { - 1 } \bar { z } \geq \chi _ { \ell , ( 2 - \beta ) \alpha } ^ { 2 } \right] - \frac { 1 } { 2 } \operatorname * { P r } \left[ \frac { m ^ { \prime } n ^ { \prime } } { m ^ { \prime } + n ^ { \prime } } \bar { z } ^ { \top } \Sigma _ { \hat { X } ^ { \prime } , \hat { Y } ^ { \prime } } ^ { - 1 } \bar { z } \geq \chi _ { \ell ,   ( 2 - \beta ) \alpha } ^ { 2 } \right] } \\ = \frac {1}{2} \Pr \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {z} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {z} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \right] = (1 - \beta / 2) \alpha . \tag {25} \\ \end{array}
$$
From Eqns. (24)-(25), we have
$$
\begin{array}{l} \Pr \left[ h = 1 \right] = \Pr \left[ h = 1 \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} > 0 \right] + \Pr \left[ h = 1 \cap \boldsymbol {F} ^ {\top} \boldsymbol {L} ^ {\prime - 1} \bar {\boldsymbol {z}} <   0 \right] \\ { = } { \operatorname * { P r } \left[ \frac { m ^ { \prime } n ^ { \prime } } { m ^ { \prime } + n ^ { \prime } } \bar { \pmb { z } } ^ { \top } \Sigma _ { \hat { X } ^ { \prime } , \hat { Y } ^ { \prime } } ^ { - 1 } \bar { \pmb { z } } \geq \chi _ { \ell , \beta \alpha } ^ { 2 } \cap \pmb { F } ^ { \top } \pmb { L } ^ { \prime - 1 } \bar { \pmb { z } } \geq 0 \right] } \\ + \operatorname * {P r} \left[ \frac {m ^ {\prime} n ^ {\prime}}{m ^ {\prime} + n ^ {\prime}} \bar {\pmb {z}} ^ {\top} \Sigma_ {\hat {X} ^ {\prime}, \hat {Y} ^ {\prime}} ^ {- 1} \bar {\pmb {z}} \geq \chi_ {\ell , (2 - \beta) \alpha} ^ {2} \cap \pmb {F} ^ {\top} \pmb {L} ^ {\prime - 1} \bar {\pmb {z}} <   0 \right] \\ = \frac {\beta \alpha}{2} + (1 - \beta / 2) \alpha = \alpha . \\ \end{array}
$$
Theorem 4 follows from Lemmas 14-16.
Recall that  $\mathcal{B}_{\langle 1\rangle},\mathcal{B}_{\langle 2\rangle},\ldots ,\mathcal{B}_{\langle s\rangle}$  are rectangle regions of a non-increasing order w.r.t.  $g(\cdot ,\cdot)$ . For each rectangle region  $\mathcal{B}_{\langle i\rangle}$ , we could define its local null hypothesis
$$
H _ {0, \langle i \rangle} \colon \boldsymbol {\mu} _ {\hat {\mathbb {P}} _ {\mathcal {B} _ {\langle i \rangle}}} = \boldsymbol {\mu} _ {\hat {\mathbb {Q}} _ {\mathcal {B} _ {\langle i \rangle}}} \quad \text {w i t h} \quad \boldsymbol {\mu} _ {\hat {\mathbb {P}} _ {\mathcal {B} _ {\langle i \rangle}}} = E _ {\hat {\boldsymbol {x}} ^ {\prime} \sim \hat {\mathbb {P}} _ {\mathcal {B} _ {\langle i \rangle}}} [ \hat {\boldsymbol {x}} ^ {\prime} ] \text {a n d} \boldsymbol {\mu} _ {\hat {\mathbb {Q}} _ {\mathcal {B} _ {\langle i \rangle}}} = E _ {\hat {\boldsymbol {y}} ^ {\prime} \sim \hat {\mathbb {Q}} _ {\mathcal {B} _ {\langle i \rangle}}} [ \hat {\boldsymbol {y}} ^ {\prime} ].
$$
From Theorem 2, the testing statistic  $\mathcal{T}(X_{\mathcal{B}_{(i)}}^{\prime},Y_{\mathcal{B}_{(i)}}^{\prime})$  follows the  $\chi^2$  distribution with freedom of  $\ell$  degrees under the local null hypothesis  $H_{0,\langle i\rangle}$ . Denote by  $\chi_{\ell}^{2}(\mathcal{T}(\hat{X}_{\mathcal{B}_{i}}^{\prime},\hat{Y}_{\mathcal{B}_{i}}^{\prime}))$  the  $p$ -value, and we have
Lemma 17. [68] The  $p$ -value  $\chi_{\ell}^{2}(\mathcal{T}(\hat{X}_{\mathcal{B}_{\langle i\rangle}},\hat{Y}_{\mathcal{B}_{\langle i\rangle}}'))$  follows a uniform distribution  $\mathcal{U}[0,1]$  under the local null hypothesis  $H_{0,\langle i\rangle}\colon \pmb{\mu}_{\hat{\mathbb{P}}_{\mathcal{B}_{\langle i\rangle}}} = \pmb{\mu}_{\hat{\mathbb{Q}}_{\mathcal{B}_{\langle i\rangle}}}$ .
We take an interactive multi-step testing procedure to identify the index set of rectangle regions of local significant differences. Define the candidate rejection set  $\mathcal{R}(t) = \{H_{0,\langle i\rangle}\}_{i = 1}^{t}$  for  $1\leq t\leq s$  with  $\mathcal{R}(0) = \emptyset$ , and exclude one null hypothesis  $H_{0,\langle t\rangle}$  at the  $t$ -th step. We could generate a sequence as follows:
$$
\left\{H _ {0, \langle i \rangle} \right\} _ {i = 1} ^ {s} = \mathcal {R} (s) \supseteq \mathcal {R} (s - 1) \supseteq \mathcal {R} (s - 2) \supseteq \dots \supseteq \mathcal {R} (0) = \emptyset . \tag {26}
$$
and it holds that  $H_{0,\langle i\rangle} = \mathcal{R}(i)\setminus \mathcal{R}(i - 1)$ . Recall the local bi-directional hypothesis
$$
h _ {\langle i \rangle} = h (\hat {X} _ {\mathcal {B} _ {\langle i \rangle}} ^ {\prime}, \hat {Y} _ {\mathcal {B} _ {\langle i \rangle}} ^ {\prime}) \quad \text {f o r} \quad i \in [ s ].
$$
Denote by  $p_*$  the parameter of significant level for the local two-sample test and masked  $p$ -value. From Theorem 4, we have  $\operatorname*{Pr}[h_{\langle i\rangle} = 1] = p_*$  under the null local hypothesis  $H_{0,\langle i\rangle}$ . We further present some useful lemmas as follows.