\section{Limit Distributions}\label{sec:Limit distribution}
For the investigation of the limit behavior of the proposed test statistic, we have to distinguish two cases.

\noindent$\boldsymbol{\truedodstat=0}$: Then, it holds $\muU=\mu^V$, see \Cref{thm:main2}.

$\boldsymbol{\truedodstat>0}$: Here, we have $\muU\neq\mu^V$, see \Cref{thm:main}.

These cases do not correspond exactly to the hypothesis $H_0$ and the alternative $H_1$. Under $H_0$ it always holds that the distributions of distances of the considered metric measure spaces are equal. Therefore, the limit distribution of $\dodstat$ in this case is essential for proving that the test induced by \eqref{eq:decision rule} asymptotically is a level $\alpha$ test. However, as already mentioned in \Cref{subsec:proposed approach} the distributions of distances do not characterize isomorphic metric measure spaces uniquely, i.e., $\muU=\mu^V$ can happen in some rare cases under $H_1$, as well. Consequently, to analyze the test's asymptotic power we assume that the distributions of distances of the considered metric measure spaces do not coincide, i.e., $\truedodstat>0$.


\subsection{Conditions on the distributions of distances}\label{subsec:conditions}


Before we come to the limit distributions of the test statistic $\dodstat$ under $H_0$ and $H_1$, we discuss \Cref{cond:firstcondition} and \Cref{cond:secondcondition}. We ensure that these conditions comprise reasonable assumptions on metric measure spaces that are indeed met in some standard examples.   
\begin{ex}\label{ex:dod3}
	\begin{enumerate} 
	\item Let $\mathcal{X}$ be the unit square in $\R^2$, $d_\mathcal{X}(x,y)=||x-y||_\infty$ for $x,y\in\R^2$ and let $\mu_\mathcal{X}$ the uniform distribution on $\mathcal{X}$. Let $X,X'\iid\muX$.
	


Then, a straight forward calculation shows that the density $u_1$ of $\dX(X,X')$ is given as
\[u_1(s)=\begin{cases}
4s^3-12s^2+8s, &\mathrm{if}~ 0\leq s\leq1\\
0, & \mathrm{else}.
\end{cases}\]
For an illustration of $u_1$ see \Cref{fig:doddensities} (a). Obviously, $u_1$ is strictly positive and continuous on $(0,1)$ and thus \Cref{cond:firstcondition} is fulfilled for any $\beta\in(0,1/2)$ in the present setting. Furthermore, we find in this framework that for $t\in(0,1)$	\begin{equation}\label{eq:example quantile function}U_1^{-1}(t)=-\sqrt{-\sqrt{t}+1}+1.\end{equation}
Since 
\[\left|(U_1^{-1})'(t)\right| =\frac{1}{4\sqrt{1-\sqrt{t}}\sqrt{t}}\leq t^{-\frac{1}{2}}(1-t)^{-\frac{1}{2}}\]
for $t\in(0,1)$, the requirements of \Cref{cond:secondcondition} are satisfied.
\item Let $\mathcal{X}$ be a disc in $\mathbb{R}^2$ with diameter one, $d_\mathcal{X}$ the Euclidean distance and $\mu_\mathcal{X}$ the uniform distribution on $\mathcal{X}$. Let $X,X'\overset{i.i.d.}{\sim}\mu_\mathcal{X}$. Then, the density $u_2$ of $d_\mathcal{X}(X,X')$ (see \cite{moltchanov2012distance}, shown in \Cref{fig:doddensities} (a)) is given as
\[u_2(s)= \begin{cases}
\begin{aligned}
8s\left(\frac{2}{\pi}\arccos(s)-\frac{2s}{\pi}\sqrt{1-s^2} \right), 
\end{aligned} &\mathrm{if}~ 0\leq s \leq 1 \\
0 ,& \mathrm{else}.
\end{cases}\]
Once again, we can easily verify \Cref{cond:firstcondition} for any $\beta\in(0,1/2)$ in this setting. 

Additionally, we find by an application of \Cref{lem:Assumptions for unif and Eucl} below with $\epsilon=1/4$, $\eta=2$ and $c_\X=\frac{16}{\pi}$ that also \Cref{cond:secondcondition} is met.
\item[3.] Let $\mathcal{X}=[0,1]^2\cup\left([5,6]\times[0,1]\right)$ be the union of two horizontally translated unit squares in $\mathbb{R}^2$. Once again, let $d_\mathcal{X}$ be the distance induced by the supremum norm and let $\mu_\mathcal{X}$ be the uniform distribution on $\mathcal{X}$. Let $X,X'\overset{i.i.d.}{\sim}\mu_\mathcal{X}$.
Then, the density $u_3$ of $\dX(X,X')$ (see \Cref{fig:doddensities} (b)) is given as
\[u_3(s)=\begin{cases}
	2s^3-6s^2+4s, &\mathrm{if}~ 0\leq s\leq1\\
	\frac{1}{2}s-2, &\mathrm{if}~ 4\leq s< 5 \\
	3-\frac{1}{2}s, &\mathrm{if}~ 5\leq s\leq 6\\
	0, & \mathrm{else}.
	\end{cases}
	\]
	We obtain that $\prob(\dX(X,X')\in[0,1])=\prob(\dX(X,X')\in[4,5])=0.5$, hence there exists no $\beta\in(0,1/2)$ such that $u_3$ is strictly positive on $[C_1,C_2]=[U^{-1}(\beta)-\epsilon,U^{-1}(1-\beta)+\epsilon]$, i.e., \Cref{cond:firstcondition} cannot be satisfied in this setting. This is due to the fact that the set $\mathcal{X}$
	is disconnected such that the diameters of both connected parts are smaller than the gap in between. In such a case the cumulative distribution function of $\dX(X,X')$ is not strictly increasing and thus \Cref{cond:firstcondition} cannot hold. The same arguments show that neither does \Cref{cond:secondcondition}. 
\end{enumerate}
\end{ex}
\begin{rem}
In the above examples we have restricted ourselves to $\X\subset\R^2$ for the ease of readability. Clearly, the same arguments (with more tedious calculations) can be applied to general $\X\subset\R^d$, $d\geq 2$.
\end{rem}
\begin{figure}
	\captionsetup[sub]{justification=centering}
	\centering
	\begin{subfigure}[c]{0.32\textwidth}
		\centering
		\includegraphics[width =0.88 \textwidth,height=0.88\textwidth]{Graphics/doddensity1plot.png}
		\caption*{~~~~~(a)}
	\end{subfigure}
\hspace*{1cm}
	\begin{subfigure}[c]{0.32\textwidth}
		\centering
		\includegraphics[width = 0.85\textwidth, height=0.85\textwidth]{Graphics/doddensity2plot.png}
				\caption*{~~~~~(b)}
	\end{subfigure}
	\caption{\textbf{Distribution of distances:} Representation of the densities $u_1$ (Figure (a), red), $u_2$ (Figure (a), blue) and $u_3$ (Figure (b)) calculated in \Cref{ex:dod3}. }
	\label{fig:doddensities}
\end{figure}
In many applications it is natural to model the objects at hand as compact subsets of $\mathbb{R}^2$ or $\mathbb{R}^3$ and to equip them with the Euclidean metric and the uniform distribution on the respective sets. Hence, the distributions of distances of these metric measure spaces deserve special attention.  Before we can state the next result, which provides simpler conditions than \Cref{cond:firstcondition} and \Cref{cond:secondcondition} in this setting, we have to introduce some notation.\\
Let $A\subset\mathbb{R}^d$, $d\geq 2$ be a bounded Borel set and let  $\lambda^d$ denote the Lebesgue measure in $\mathbb{R}^d$. Let $\mathbb{S}_{d-1}$ stand for the unit sphere in $\Rd$. Then, $y\in \Rd$ is determined by its polar coordinates $(t,v)$, where $t=\left\| y\right\|_2$ and $v\in\mathbb{S}_{d-1}$ is the unit length vector $y/t$. Thus, we define the \textit{covariance function} \cite[Sec. 3.1]{stoyan2008stochastic} for $y=tv\in\Rd$ as
\[K_A(t,v)=K_A(y)=\lambda^d\left( A\cap(A-y)\right),\]
where $A-y=\left\lbrace a-y:a\in A\right\rbrace $, and introduce the \textit{isotropized set covariance function} \cite[Sec. 3.1]{stoyan2008stochastic}
\[k_A(t)=\frac{1}{(\lambda^d(A))^2}\int_{\mathbb{S}_{d-1}}\!K_A(t,v)\,dv.\]
Furthermore, we define the diameter of a metric space $\left(\X,\dX\right)$ as $\diam{\X}=\sup\{\dX(x_1,x_2):x_1,x_2\in\X\} $.
\begin{lemma}\label{lem:Assumptions for unif and Eucl} \ 
	Let $\mathcal{X}\subset\mathbb{R}^d$, $d\geq2$, be a compact Borel set, $\dX$ the Euclidean metric and $\muX$ the uniform distribution on $\mathcal{X}$. Let $\diam{\X}=D$.
	\begin{itemize}[leftmargin=*]
		\item[(i)] If $k_\X$ is strictly positive on $[0,D)$, then the induced metric measure space $\mmspaceX$ meets the requirements of \Cref{cond:firstcondition} for any $\beta\in(0,1/2)$.
		\item[(ii)] If additionally there exists $\epsilon>0$ and $\eta>0$ such that
		\begin{enumerate}
		\item the function $k_\X$ is monotonically decreasing on $(D-\epsilon,D)$;
		\item we have $k_\X(t)\geq c_\X (D-t)^\eta$ for $t\in (D-\epsilon,D)$, where $c_\X$ denotes a finite, positive constant,
		\end{enumerate}
	then $\mmspaceX$ also fulfills the requirements of \Cref{cond:secondcondition}.
	\end{itemize}
\end{lemma}
The full proof of the above lemma is deferred to Section B.1 of \citet{supplement}.
\subsection{The Case \texorpdfstring{\bm{$\truedodstat=0$}}{Case 1}}\label{subsec:first case} Throughout this subsection we assume that the distribution of distances of the two considered metric measure spaces $\mmspaceX$ and $\mmspaceY$ are equal, i.e., that $\muU=\mu^V$. Assume that $X_1,\dots,X_n\iid\muX$ and $Y_1,\dots,Y_m\iid\muY$ are two independent samples. The next theorem states that $\dodstat$, based on these samples, converges, appropriately scaled, in distribution to the integral of a squared Gaussian process. The case $\beta\in(0,1/2)$ is considered in part $(i)$, whereas the case $\beta=0$ is considered in part $(ii)$. 

\begin{thm}\label{thm:main2} Assume \Cref{cond:setting} and suppose that $\muU=\mu^V$.\begin{itemize}[leftmargin=*]
\item[(i)] Let \Cref{cond:firstcondition} be met and let $m,n\to\infty$ such that ${n}/({n+m})\to\lambda\in \left(0,1 \right) $. Then, it follows
	\begin{align*}
	\frac{nm}{n+m}\int_{\beta}^{1-\beta}\!\left(U_n^{-1}(t)-V_m^{-1}(t)\right)^2 \, dt\rightsquigarrow\Xi\coloneqq\int_{\beta}^{1-\beta}\!\mathbb{G}^2(t) \, dt,
	\end{align*}
	where $\mathbb{G}$ is a centered Gaussian process with covariance
	\begin{equation}\label{eq:definition of the covariance}
	\Cov\left(\mathbb{G}(t),\mathbb{G}(t') \right)\!=\! \frac{4}{(u\circ U^{-1}(t))(u\circ U^{-1}(t'))}\Gamma_{\dX}(U^{-1}(t),U^{-1}(t')). \\ 
	\end{equation}
	Here,
	\begin{align*}
	\Gamma_{\dX}\left(t,t'\right)= \int\!\int\!\mathds{1}_{\left\lbrace d_\mathcal{X}(x,y)\leq t\right\rbrace }\,d\muX(y)\int\!\mathds{1}_{\left\lbrace d_\mathcal{X}(x,y)\leq t'\right\rbrace }\,d\muX(y)\,d\muX(x)\\
	-\int\!\int \mathds{1}_{\left\lbrace d_\mathcal{X}(x,y)\leq t\right\rbrace }\,d\muX(y)\,d\muX(x)\int\!\int \!\mathds{1}_{\left\lbrace d_\mathcal{X}(x,y)\leq t'\right\rbrace }\,d\muX(y)\,d\muX(x). 
	\end{align*}
	\item[(ii)] If we assume \Cref{cond:secondcondition} instead of \Cref{cond:firstcondition}, then the analogous statement holds for the untrimmed version, i.e., for $\beta =0$.
		\end{itemize}
\end{thm}
The main ideas for the proof of \Cref{thm:main2} are illustrated in \Cref{appendix:proofs} and the full proof can be found in the supplementary material \cite[Sec. B.2]{supplement}.

\begin{ex}\label{ex:explixitvar}
	Recall \Cref{ex:dod3}, i.e., $\mathcal{X}$ is the unit square in $\mathbb{R}^2$, $d_\mathcal{X}$ is the distance induced by the supremum norm and $\mu_\mathcal{X}$ is the uniform distribution on $\mathcal{X}$. Let $X,X'\iid\mu_\mathcal{X}$. From \eqref{eq:example quantile function}, we obtain
	\[U_1(t)=\prob\left(\left\| X-X'\right\|_\infty\leq t\right)=\begin{cases}
	0, &\mathrm{if}~t\leq 0\\
	\left(2t-t^2 \right)^2,&\mathrm{if}~ 0\leq t\leq 1\\
	1, & t\geq1. \end{cases}\]
	Hence, in order to obtain an explicit expression of the covariance structure in the present setting, it remains to determine the first term of $\Gamma_{\dX}$	\begin{align*}
	\Gamma_{\dX,1}(t,t')&\coloneqq\int\!\int\!\mathds{1}_{\left\lbrace d_\mathcal{X}(x,y)\leq t\right\rbrace }\,d\muX(y)\int\!\mathds{1}_{\left\lbrace d_\mathcal{X}(x,y)\leq t'\right\rbrace }\,d\muX(y)\,d\muX(x)\\
	


&=\begin{cases}
	\left(-\frac{1}{3}t'^3-t'^2t-2t't^2+4t't\right)^2, &\mathrm{if}~ t'\leq t<1/2\\
	\left(-\frac{1}{3}t'^3-t'^2t-2t't^2+4t't\right)^2 ,&\!\begin{aligned}\mathrm{if}~& t'<1/2\leq t,\\~& t'\leq 1-t \end{aligned} \\
	\left(-(t'-t)^2-t't^2+t'+\frac{1}{3}t^3+t-\frac{1}{3}\right)^2, &\!\begin{aligned}\mathrm{if}~& t'<1/2\leq t,\\~& t'> 1-t\end{aligned}\\
	\left(-(t'-t)^2-t't^2+t'+\frac{1}{3}t^3+t-\frac{1}{3}\right)^2, &\mathrm{if}~ 1/2\leq t'\leq t\leq 1. \end{cases}
	\end{align*}


\end{ex}
Based on the limit distribution derived in \Cref{thm:main2} it is possible to construct an asymptotic level $\alpha$ test using (estimates of) the theoretical $1-\alpha$ quantiles of $\Xi$, denoted as $\xi_{1-\alpha}$, in \eqref{eq:decision rule}. However, in order to study its finite sample bias, the following bound is helpful (for its proof see \Cref{subsec:proof of the finite sample boud} and \citet[Sec. B.3]{supplement}).
\begin{thm}\label{thm:finite sample bound for p=2}
	Let $\beta \in [0,1/2)$, let \Cref{cond:setting} be met and suppose that $\mu^U=\mu^V$. Further, let \[J_2\left(\mu^U\right) =\int_{-\infty}^{\infty}\! \frac{ U(t)(1-U(t)) }{u(t)}\,dt<\infty.\]
	Then it holds for $m,n\geq 3$ that
	\[\Eargs{\dodstatnn}\leq \left( \frac{8}{n+1}+\frac{8}{m+1}\right) J_2(\muU).\]
\end{thm}
 For instance in the setting of \Cref{ex:explixitvar} it holds $J_2\left(\mu^U\right)=\frac{5}{48}<\infty$ and thus $\Eargs{\dodstatnn}\leq \frac{5}{6}\left( \frac{1}{n+1}+\frac{1}{m+1} \right) $ for $m,n\geq 3$.
\subsection{The Case \texorpdfstring{$\bm{\truedodstat>0$}}{Case 2}} \label{subsec:secondcase}
 In this subsection, we are concerned with the behavior of $\dodstat$ given that the distributions of distances of the metric measure spaces $\mmspaceX$ and $\mmspaceY$ do not coincide.
 


Just as for \Cref{thm:main2}, we distinguish the cases $\beta\in(0,1/2)$ and $\beta = 0$. 
\begin{thm}\label{thm:main} Assume \Cref{cond:setting}.
	\begin{itemize}[leftmargin=*]
	\item[(i)] Assume that \Cref{cond:firstcondition} holds, let $m,n\to\infty$ such that $\frac{n}{n+m}\to\lambda\in \left(0,1 \right) $ and let $\truetruncateddod> 0$.
	Then, it follows that
		\[\sqrt{\frac{nm}{n+m}}\left(\dodstat-\truetruncateddod \right)\]
		converges in distribution to a normal distribution with mean 0 and variance
		\begin{align*}
		&16\lambda\!\!\!\!\!\!\!\int\limits_{U^{-1}(\beta)}^{U^{-1}(1-\beta)}\int\limits_{U^{-1}(\beta)}^{U^{-1}(1-\beta)}\!\!\!\!\!\!\!\!(x-V^{-1}(U(x)))(y-V^{-1}(U(y)))\Gamma_{\dX}\left(x,y\right) dxdy\\
		+&16(1-\lambda)\!\!\!\!\!\!\!\int\limits_{V^{-1}(\beta)}^{V^{-1}(1-\beta)}\int\limits_{V^{-1}(\beta)}^{V^{-1}(1-\beta)}\!\!\!\!\!\!\!\!(U^{-1}(V(x))-x))(U^{-1}(V(y))-y)\Gamma_{\dY}\left(x,y\right) dxdy\label{eq:maincorvar}.
		\end{align*}
		Here, $\Gamma_{\dX}\left(x,y\right)$ is as defined in \Cref{thm:main2} and $\Gamma_{\dY}\left(x,y\right)$ is defined analogously.
		\item[(ii)] If we assume \Cref{cond:secondcondition} instead of \Cref{cond:firstcondition}, then the analogous statement holds for the untrimmed version, i.e., for $\beta =0$.
	\end{itemize}
\end{thm}
The proof of \Cref{thm:main} is sketched in \Cref{appendix:proofs}. A detailed version is given in Section B.4 of \cite{supplement}.
\begin{rem}\label{rem:maintheoremextraassumption}
	The assumptions of \Cref{thm:main} $(i)$ include that $\beta$ is chosen such that
	\begin{equation*}\label{assump:slb}
	\truetruncateddod> 0.
	\end{equation*}
	 Suppose on the other hand that $\muU\neq\mu^V$, but $\truetruncateddod= 0$, i.e., their quantile functions agree Lebesgue almost surely on the considered interval $[\beta,1-\beta]$. Then, the limits found in \Cref{thm:main} are degenerate and it is easy to verify along the lines of the proof of \Cref{thm:main2} that $\dodstat$ exhibits the same distributional limit as in the case $\truedodstat=0$.
\end{rem}
\begin{rem}
	So far we have restricted ourselves to the case $p=2$. However, most of our findings directly translate to results for the statistic $\untruncateddodstat_p$, $p\in[1,\infty)$, defined in \eqref{eq:introlowerboundempversion}. Using the same ideas one can directly derive \Cref{thm:main2} and \Cref{thm:finite sample bound for p=2} for (a trimmed version) of $\untruncateddodstat_p$ (see Sections B.2 and B.3 of \citet{supplement}) under slightly different assumptions. Only the proof of \Cref{thm:main} requires more care (see \cite[Sec. B.4]{supplement}).
\end{rem}
{"config": "arxiv", "file": "2006.12287/Dod-Paper(ArXiv)/Sections/Dod-LimitDistribution.tex"}