#  Quantiles, Ranks and Signs in Metric Spaces

Hang Liu (a) Xueqin Wang  (b) and Jin Zhu(c)
for the Alzheimer’s Disease Neuroimaging Initiative
(a)International Institute of Finance, School of Management,
University of Science and Technology of China, Hefei, China
Email<EMAIL_ADDRESS>
(b)International Institute of Finance, School of Management,
University of Science and Technology of China, Hefei, China
Email<EMAIL_ADDRESS>
(c) Department of Statistical Science, Sun Yat-Sen University,
Guangzhou, China
Email<EMAIL_ADDRESS>
###### Abstract

Non-Euclidean data is currently prevalent in many fields, necessitating the
development of novel concepts such as distribution functions, quantiles,
rankings, and signs for these data in order to conduct nonparametric
statistical inference. This study provides new thoughts on quantiles, both
locally and globally, in metric spaces. This is realized by expanding upon
metric distribution function proposed by (Wang et al., 2021). Rank and sign
are defined at both the local and global levels as a natural consequence of
the center-outward ordering of metric spaces brought about by the local and
global quantiles. The theoretical properties are established, such as the
root-$n$ consistency and uniform consistency of the local and global empirical
quantiles and the distribution-freeness of ranks and signs. The empirical
metric median, which is defined here as the 0th empirical global metric
quantile, is proven to be resistant to contaminations by means of both
theoretical and numerical approaches. Quantiles have been shown valuable
through extensive simulations in a number of metric spaces. Moreover, we
introduce a family of fast rank-based independence tests for a generic metric
space. Monte Carlo experiments show good finite-sample performance of the
test. Quantiles are demonstrated in a real-world setting by analysing
hippocampal data.

Keywords Metric space, Local metric quantile, Global metric quantile, Metric
rank, Metric sign

##  1 Introduction

Data in non-Euclidean spaces can be found in various fields. Examples include
directional data (Marinucci et al., 2008; Marinucci and Peccati, 2011),
symmetric positive definite (SPD) matrices (Smith et al., 2013), samples of
probability distribution functions in Wasserstein spaces (Petersen et al.,
2021), to name only a few. In order to perform nonparametric statistical
inference and analysis for such data, we need to develop basic nonparametric
concepts including quantiles, ranks and signs for non-Euclidean data.

Unlike the real line, however, there is no canonical ordering in non-Euclidean
spaces which makes definition of those tools quite challenging. To tackle this
issue, various types of depths have been proposed to introduce ordering in
non-Euclidean spaces, including the angular Tukey depth (Liu and Singh, 1992)
and distance-based depth (Pandolfo et al., 2018) both for spherical data, the
intrinsic zonoid depth for SPD matrices (Chau et al., 2019), the halfspace
depth for curve data (De Micheaux et al., 2021), and so on. These notions of
depths, however, focus only on a specific metric space. Relevant literature on
general metric spaces are more scarce though. By defining halfspace through
the underlying distance metric, Dai et al. (2022) proposed a notion of depth
at a point as the least probability measure of the halfspaces containing this
point. Similar to the halfspace depth in the Euclidean space, the depth of Dai
et al. (2022) is computational inefficient. Another type of depth is the depth
profile proposed by Dubey et al. (2022), referring to the distribution of the
distances between a point and the other elements in the metric space.

Different from Dai et al. (2022) and Dubey et al. (2022), where depths are
defined but concepts of quantiles are missing, this paper proposes novel
concepts of quantiles from both the local and global perspectives for general
metric spaces. Our definition is based on the idea of the metric distribution
function (MDF), which is the probability measure of a closed ball
characterized by two points in metric space (Wang et al., 2021). According to
the MDF levels, our local quantiles at a specific location in the metric space
are defined. In order to define quantiles from a global perspective, we take a
quantity resulting from aggregating the local information of the MDF for all
points in the metric space, and define the global quantiles based on the
levels of the distribution function of this quantity. The empirical versions
of the local and global quantiles are the defined as the discrete sample
versions of their population counterparts. Observing the local and global
quantiles induces center-outward orderings in the metric space locally and
globally, respectively, we therefore define the local and global ranks and
signs based on their empirical quantile levels.

In addition to attractive interpretation as described previously, our novel
concepts of the local and global quantiles, ranks and signs also enjoy a
number of desirable theoretical properties. For example, both the empirical
local and global quantiles are root-$n$ and uniformly consistent; the local
and global ranks and signs are distribution-free. Compared with the depths in
Dai et al. (2022) and Dubey et al. (2022), our empirical global quantiles are
easy-to-implement in practice, since the computation is straightforward and
does not involve any optimization process, and is computationally efficient
with complexity $O(n^{2}\log(n))$ when the global quantiles are computed for
all the $n$ sample points. As illustrated via numerical study in Section 5,
distributions in various metric spaces are well-characterized by the global
quantiles and the empirical quantiles have good finite-sample performance,
manifesting reasonableness of our novel concepts. Moreover, theoretical
analysis of the breakdown point and simulation study under various metric
spaces show that our empirical metric median, defined as the $0$th empirical
global metric quantile, is more robust against contamination than the metric
halfspace median of Dai et al. (2022) and the transport median of Dubey et al.
(2022).

The global ranks and signs defined in this paper naturally allow us to define
rank-based tests for a generic metric space, which have been seldom considered
in the literature of the rank-based statistical inference. As an illustration,
in Section 6, we consider a class of rank-based two-sample independence tests,
which are computationally efficient with complexity of $O(n^{2}\log(n))$.
Monte Carlo experiments show consistency of our test and good finite-sample
performance even under heavy-tailed distributions.

This paper is organized as follows. Section 2 introduces the MDF, its
empirical version and the asymptotic properties in Wang et al. (2021), which
are the building blocks of the main concepts of this paper. Section 3 and
Section 4, from the local and global perspectives, respectively, defines the
metric quantile, rank and sign and establishes the asymptotic results,
including the root-$n$ and uniform consistency, of the empirical metric
quantile. Moreover, computation aspects and robustness of the global metric
quantile are discussed in Section 4. Section 5 illustrates the concepts of the
global metric quantile and its empirical version via Monte Carlo experiments
under various metric spaces. Numerical analysis comparing robustness of the
empirical metric median and the counterparts of Dai et al. (2022) and Dubey et
al. (2022) is also included in Section 5. Section 6 proposes the rank-based
two-sample independence test and investigates its finite-sample performance
via Monte Carlo experiments. Analysis of the hippocampus data based on the
local and global metric quantiles is given in Section 7. Section 8 concludes
the paper and provides some perspectives for future research. All proofs, some
preliminaries, simulation details and additional results, discussion on the
computation algorithm are collected in Appendices.

##  2 Metric distribution function and its empirical version

###  2.1 Metric distribution function

An order pair $({\cal M},d)$ is called metric space if ${\cal M}$ is a set and
$d$ is a metric or distance on ${\cal M}$ (see Appendix A.1 for some examples
of non-Euclidean metric spaces that have wide applications in various fields).
Throughout the paper, we denote by $\bar{B}({\bf u},r):=\\{{\bf v}:d({\bf
u},{\bf v})\leq r\\}$ the closed ball with the center ${\bf u}$ and radius
$r\geq 0$ on $({\cal M},d)$, and by $B({\bf u},r):=\\{{\bf v}:d({\bf u},{\bf
v})<r\\}$ the corresponding open ball.

The linearity in an Euclidean space allows us to use hypercubes to define the
distribution function, in a general metric space, however, such linearity does
not exist and we hence need to adopt other approaches to define the
distribution function. Wang et al. (2021) proposed the concept of the metric
distribution function (MDF) in a metric space, overcoming this difficulty by
utilizing the underlying metric and working with the local probability measure
at a fixed point in the metric space. In this section, we briefly introduce
the MDF and its empirical version, which are important ingredients for
defining quantiles in the metric space.

Denote by $\mu$ a probability measure associated with a random variable ${\bf
X}\in{\cal M}$. Let $\delta({\bf u},{\bf v},{\bf X}):=I({\bf X}\in\bar{B}({\bf
u},r)),$ where $I(\cdot)$ is the indicator function. The metric distribution
function of $\mu$ on ${\cal M}$ measures the probability that ${\bf X}\in{\cal
M}$ is contained in $\bar{B}({\bf u},r)$ and is defined as

$F_{\mu}^{\cal M}({\bf u},{\bf v})\coloneqq\mu(\bar{B}({\bf u},{\bf r}))={\rm
E}(\delta({\bf u},{\bf v},{\bf X}))\vspace{-2mm}$

for ${\bf u},{\bf v}\in{\cal M}.$ Different from the traditional distribution
function in an Euclidean space, which is a function of one variable and is
defined from a global perspective, $F_{\mu}^{\cal M}$ is a probability
distribution function defined locally (at ${\bf u}\in{\cal M}$) for the closed
ball $\bar{B}({\bf u},r)\subset{\cal M}$ characterized by two variables ${\bf
u}$ and ${\bf v}$.

###  2.2 Empirical metric distribution function

Based on the definition of the MDF, its empirical version can naturally be
defined as follows. Let ${\bf X}^{(n)}\coloneqq\\{{\bf X}_{1},\ldots,{\bf
X}_{n}\\}$ be an i.i.d. sample generated from the probability measure $\mu$ on
${\cal M}$. For ${\bf u},{\bf v}\in{\cal M}$, the empirical metric
distribution function (EMDF) is the empirical probability measure of the
sample being contained in $\bar{B}({\bf u},r)$ and is defined as

$F_{\mu,n}^{\cal M}({\bf u},{\bf
v})\coloneqq\frac{1}{n}\sum_{i=1}^{n}\delta({\bf u},{\bf v},{\bf X}_{i}).$ (1)

Similar to the empirical distribution function on the real line,
$F_{\mu,n}^{\cal M}$ also satisfies the Glivenko-Cantelli and Donsker
asymptotics which are important properties for conducting nonparametric
statistical inference in a metric space and for establishing asymptotics of
the quantiles proposed in this paper. See Appendix A.2 for details of the
Glivenko-Cantelli and Donsker properties.

Define the collection of the indicator functions of closed balls on ${\cal M}$
by

${\cal F}\coloneqq\\{\delta({\bf u},{\bf v},\cdot):{\bf u},{\bf v}\in{\cal
M}\\}\vspace{-2mm}$

and let ${\cal F}({\bf X}^{(n)})\coloneqq\\{h({\bf X}_{1}),\ldots,h({\bf
X}_{n})|h\in{\cal F}\\}$. The Glivenko-Cantelli property of the EMDF relies on
the following assumption.

###### Assumption 1

$\mu$ on ${\cal M}$ satisfies that

$\frac{1}{n}{\rm E}_{{\bf X}}[\log({\rm card}({\cal F}({\bf
X}^{(n)})))]\rightarrow 0,\vspace{-2mm}$

where ${\rm card}$ denotes the cardinality of a set.

###### Remark 1

Assumption 1 is referred to as entropy condition (van der Vaart and Wellner,
1996, Chapter 2) and it measures the number of balls needed to cover the
Glivenko-Cantelli class. This assumption is quite mild as it is satisfied by a
large class of metric spaces, which, according to Wang et al. (2021), includes
(i) $(\mathbb{R}^{p},\|\cdot\|_{q}),q\geq 1$; (ii) the space of all smooth
regular curves equipped with geodesic distance; (iii) a hypersphere equipped
with geodesic distance; (iv) a set of polygonal curves in $\mathbb{R}^{p}$
with the Hausdorff distance for the Fréchet distance (Driemel et al., 2019);
(v) a separable Hilbert space with $\mu$ having support on a finite
dimensional subspace. Moreover, it is fulfilled by (vi) the manifold of
symmetric positive definite matrices of a fixed size, and (vii) the
Wasserstein space (see Example 4 in Section A.1) that the distributions in
${\cal M}$ are absolutely continuous (with respect to the Lebesgue measure)
with uniform smooth densities in a closed interval (Dubey et al., 2022), and
so on.

The EMDF moreover enjoys the Donsker property under the following assumption.

###### Assumption 2

${\cal F}$ is a VC class111See van der Vaart and Wellner (1996) for the
definition. with VC-dimension $V({\cal F})<\infty$.

###### Remark 2

According to Wang et al. (2021) and Dubey et al. (2022), Assumption 2 is
satisfied by a large class of metric spaces including the cases (i)-(iv), (vi)
and (vii) in Remark 1. In fact, it follows from van der Vaart and Wellner
(1996, Theorem 2.6.4) that Assumption 2 implies Assumption 1; hence the
Glivenko-Cantelli class is larger than the Donsker class.

##  3 Local metric quantile and its empirical version

###  3.1 Local metric quantile

Once we have the definition of the MDF for the metric space $({\cal M},d)$,
the quantile can naturally be defined according to level of the MDF. Note
that, in contrast to the traditional distribution function in an Euclidean
space, the MDF is a probability distribution function defined locally at ${\bf
u}\in{\cal M}$; hence, the quantile in Definition 1 is also defined from a
local perspective for each ${\bf u}\in{\cal M}$. It is a measure of
outlyingness with respect to a fixed point in the metric space.

###### Definition 1

Given a point ${\bf u}\in{\cal M}$, the $\tau$th quantile ($\tau\in[0,1]$) of
$\mu$ on ${\cal M}$ is

$q^{\cal M}({\bf u},\tau)\coloneqq\\{{\bf v}\in{\cal M}:F_{\mu}^{\cal M}({\bf
u},{\bf v})=\tau\\},\vspace{-2mm}$

the $\tau$th quantile region is

$\bar{q}^{\cal M}({\bf u},\tau)\coloneqq\\{{\bf v}\in{\cal M}:F_{\mu}^{\cal
M}({\bf u},{\bf v})\leq\tau\\},\vspace{-2mm}$

and the $\tau$th inner quantile region is

$\tilde{q}^{\cal M}({\bf u},\tau)\coloneqq\\{{\bf v}\in{\cal M}:F_{\mu}^{\cal
M}({\bf u},{\bf v})<\tau\\}.\vspace{-3mm}$

Throughout, we make the following mild assumption on $\mu$ which entails some
desirable properties of the quantiles such as nestedness and
$\sqrt{n}$-consistency of the empirical local metric quantile defined in
Section 3.2.

###### Assumption 3

$\mu$ is absolutely continuous with density function $f$, which is positive
and continuous everywhere on ${\cal M}$.

In analogue to the quantile regions on the real line, the quantile regions in
Definition 1 enjoy the following property of nestedness. It implies that the
quantile $q^{\cal M}({\bf u},\tau)$ induces a center-outward ordering of
nested regions, with ${\bf u}$ being the center. See Appendix B for its proof.

###### Proposition 1

If Assumption 3 holds, then for $0\leq\tau_{1}<\tau_{2}\leq 1$ and any ${\bf
u}\in{\cal M}$, $\bar{q}^{\cal M}({\bf u},\tau_{1})\subsetneq\bar{q}^{\cal
M}({\bf u},\tau_{2})$.

###  3.2 Empirical local metric quantile

Given an i.i.d. sample ${\bf X}^{(n)}\coloneqq\\{{\bf X}_{1},\ldots,{\bf
X}_{n}\\}$ generated from the probability measure $\mu$ on ${\cal M}$, similar
to Definition 1, we can naturally define the empirical version of the local
metric quantile based on the EMDF. It measures the outlyingness of the sample
with respect to a fixed point in the metric space.

###### Definition 2

Given a point ${\bf u}\in{\cal M}$, the $\tau$th empirical quantile
($\tau\in[0,1]$) of $\mu$ on ${\cal M}$ is

$q_{n}^{\cal M}({\bf u},\tau)\coloneqq\begin{cases}{\bf
u},&\tau\in[0,\frac{1}{n})\\\ \operatorname*{arg\,min}_{{\bf X}_{i}\in{\bf
X}^{(n)}}F_{\mu,n}^{\cal M}({\bf u},{\bf X}_{i})\quad{\rm s.t.}\quad
F_{\mu,n}^{\cal M}({\bf u},{\bf
X}_{i})\geq\tau,&\tau\in[\frac{1}{n},1].\end{cases}$

###### Remark 3

Note that the $\tau$th population quantile in Definition 1 yields a set of
contour in ${\cal M}$, whereas the empirical version, with probability one, is
a point in ${\cal M}$ due to the absolute continuity of $\mu$. In fact, the
$\tau$th sample quantile may alternatively be defined as a set of points
through factorizing $n$, which would yield a set of contour in ${\cal M}$
after performing interpolation. Specifically, by factorization of
$n=n_{1}n_{2}+n_{0}$, where $n_{1},n_{2}\rightarrow\infty$ as
$n\rightarrow\infty$ and $n_{0}$, as the multiplicity of the $0$th sample
quantile, is a small number, one can define the $\tau$th ($\tau\geq 1/n_{2}$)
sample quantile as a set of $n_{1}$ points according to the ordering of
$F_{\mu,n}^{\cal M}({\bf u},{\bf X}_{i}),i=1,\ldots,n$. In fact, this approach
is equivalent to defining $\tau$th sample quantile as the set of
$[\tau,\tau+n_{1}/n)$th sample quantiles in Definition 2. This type of
definition, however, usually requires a relatively large $n$ (especially when
the dimension is large) to obtain a regular contour. In the context of an
Euclidean space, defining the sample contour through the factorization of $n$
can be found in Hallin et al. (2021). Similar remark also applies to the
global empirical metric quantile defined in Section 4.2.

Proposition 2 states that the $\tau$th empirical local metric quantile, with
probability one, lies in a small neighbourhood (of order $n^{-1/2}$) of the
$\tau$th local quantile contours, which is generated by the difference of two
nested inner quantile regions. See Appendix B for its proof.

###### Proposition 2

For any ${\bf u}\in{\cal M}$, when $\tau\in[0,\frac{1}{n})$, $q_{n}^{\cal
M}({\bf u},\tau)=q^{\cal M}({\bf u},0)$; when $\tau\in[\frac{1}{n},1]$, under
Assumptions 2 and 3, with probability one,

$q_{n}^{\cal M}({\bf u},\tau)\subset\tilde{q}^{\cal M}({\bf
u},\tau+\frac{1}{n}+\frac{1}{\sqrt{n}}\mathbb{G}_{\mu,n}^{\cal M}({\bf
u},q_{n}^{\cal M}({\bf u},\tau)))\setminus\tilde{q}^{\cal M}({\bf
u},\tau+\frac{1}{\sqrt{n}}\mathbb{G}_{\mu,n}^{\cal M}({\bf u},q_{n}^{\cal
M}({\bf u},\tau))),$

where $\mathbb{G}_{\mu,n}^{\cal M}({\bf u},{\bf v}):=\sqrt{n}(F_{\mu,n}^{\cal
M}({\bf u},{\bf v})-F_{\mu}^{\cal M}({\bf u},{\bf v})),\,{\bf u},{\bf
v}\in{\cal M}$.

The following result moreover states the uniform consistency (in terms of
${\bf u}$ and $\tau$) of the empirical local metric quantile. See Appendix B
for its proof.

###### Proposition 3

If Assumption 1 holds, then

$\underset{n\rightarrow\infty}{\lim}\underset{{\bf u}\in{\cal
M},\tau\in[0,1]}{\sup}{\rm P}(q_{n}^{\cal M}({\bf u},\tau)\not\subset q^{\cal
M}({\bf u},\tau))=0.$

###  3.3 Local metric ranks and signs

On a real line, the distribution function, as a monotonic increasing map from
$\mathbb{R}$ to $[0,1]$, introduces the left-to-right order relation. Its
empirical version, also as a monotonic increasing map from the i.i.d. sample
to the regular grid on $[0,1]$, naturally allows us to define ranks of a
sample by multiplication of the sample size $n$ (or $n+1$). In our setting of
a general metric space, when a point ${\bf u}\in{\cal M}$ is given, we can
similarly define ranks locally by the local empirical distribution function.
Moreover, signs can also be defined locally according to the sign of
$F_{\mu,n}^{\cal M}({\bf u},{\bf X}_{j})n/(n+1)-1/2,1\leq j\leq n.$

###### Definition 3

Let $\\{{\bf X}_{1},\ldots,{\bf X}_{n}\\}$ be an i.i.d. sample generated from
the probability measure $\mu$ on ${\cal M}$. Then given a point ${\bf
u}\in{\cal M}$, the local metric rank of ${\bf X}_{j},1\leq j\leq n$ is

$R_{\mu,n}^{\cal M;{\rm loc}}({\bf u},{\bf X}_{j}):=nF_{\mu,n}^{\cal M}({\bf
u},{\bf X}_{j})=\sum_{i=1}^{n}\delta({\bf u},{\bf X}_{j},{\bf X}_{i})$

and the local metric sign of ${\bf X}_{j}$ is

$S_{\mu,n}^{\cal M;{\rm loc}}({\bf u},{\bf X}_{j}):={\rm
sign}\left(\frac{nF_{\mu,n}^{\cal M}({\bf u},{\bf
X}_{j})}{n+1}-\frac{1}{2}\right)={\rm sign}\left(\frac{R_{\mu,n}^{\cal M;{\rm
loc}}({\bf u},{\bf X}_{j})}{n+1}-\frac{1}{2}\right).$

An important property that makes ranks and signs successful tools for
statistical inference is their distribution-freeness. Similar to their
counterparts on the real line, this property also holds for our local metric
ranks and signs. See Appendix B for its proof.

###### Proposition 4

Let $\\{{\bf X}_{1},\ldots,{\bf X}_{n}\\}$ be an i.i.d. sample generated from
the probability measure $\mu$ on ${\cal M}$. Then given a point ${\bf
u}\in{\cal M}$,

  1. (i)

$F_{\mu,n}^{\cal M}({\bf u},{\bf X}^{(n)}):=(F_{\mu,n}^{\cal M}({\bf u},{\bf
X}_{1}),F_{\mu,n}^{\cal M}({\bf u},{\bf X}_{2}),\ldots,F_{\mu,n}^{\cal M}({\bf
u},{\bf X}_{n}))$ is uniformly distributed over the $n!$ permutations of
$(1/n,2/n,\ldots,1)$;

  2. (ii)

$R_{\mu,n}^{\cal M;{\rm loc}}({\bf u},{\bf X}^{(n)}):=(R_{\mu,n}^{\cal M;{\rm
loc}}({\bf u},{\bf X}_{1}),\ldots,R_{\mu,n}^{\cal M;{\rm loc}}({\bf u},{\bf
X}_{n}))$ is uniformly distributed over the $n!$ permutations of
$(1,\ldots,n)$;

  3. (iii)

${\rm P}(S_{\mu,n}^{\cal M;{\rm loc}}({\bf u},{\bf
X}_{j})=1)=\frac{\left\lfloor n/2\right\rfloor}{n}={\rm P}(S_{\mu,n}^{\cal
M;{\rm loc}}({\bf u},{\bf X}_{j})=-1)$ and ${\rm P}(S_{\mu,n}^{\cal M;{\rm
loc}}({\bf u},{\bf X}_{j})=0)=1-\frac{2\left\lfloor n/2\right\rfloor}{n}$.

###  3.4 Isometry-invariance of the local concepts

Now we discuss the equivariance properties of the distribution functions,
local quantiles, ranks and signs. Let $({\cal M},d)$ and $({\cal
M}^{\prime},d^{\prime})$ be two metric spaces, and $T:{\cal M}\rightarrow{\cal
M}^{\prime}$ be an isometry; that is

$d^{\prime}(T{\bf u},T{\bf v})=d({\bf u},{\bf v}),\forall{\bf u},{\bf
v}\in{\cal M}.$

Proposition 5 states that the distribution function, its empirical version,
local ranks and signs are invariant under an isometric transformation. The
local quantile and its empirical version are also invariant up to an isometric
transformation. See Appendix B for its proof.

###### Proposition 5

Let $\\{{\bf X}_{1},\ldots,{\bf X}_{n}\\}$ be i.i.d. samples generated from
the probability measure $\mu$ on ${\cal M}$. Then

  1. (i)

$F_{\mu}^{{\cal M}^{\prime}}(T{\bf u},T{\bf v})=F_{\mu}^{\cal M}({\bf u},{\bf
v})$ and $F_{\mu,n}^{{\cal M}^{\prime}}(T{\bf u},T{\bf v})=F_{\mu,n}^{\cal
M}({\bf u},{\bf v})$

  2. (ii)

$q^{{\cal M}^{\prime}}(T{\bf u},\tau)=Tq^{\cal M}({\bf u},\tau)$ and
$q_{n}^{\cal M^{\prime}}(T{\bf u},\tau)=Tq_{n}^{\cal M}({\bf u},\tau)$

  3. (iii)

$R_{\mu,n}^{{\cal M}^{\prime};{\rm loc}}(T{\bf u},T{\bf
X}_{j})=R_{\mu,n}^{{\cal M};{\rm loc}}({\bf u},{\bf X}_{j})$ and
$S_{\mu,n}^{{\cal M}^{\prime};{\rm loc}}(T{\bf u},T{\bf
X}_{j})=S_{\mu,n}^{{\cal M};{\rm loc}}({\bf u},{\bf X}_{j})$ for
$j=1,\ldots,n$.

##  4 Global metric quantile and its empirical version

###  4.1 Global metric quantile

In contrast to the local metric quantile in Section 3, this section defines
the quantile from a global perspective. Noticing that $F_{\mu}^{\cal M}({\bf
X},{\bf u})$ provides probability information for ${\bf u}$ locally at ${\bf
X}$, to define the global quantile, we consider aggregating the local
information of $F_{\mu}^{\cal M}({\bf X},{\bf u})$ for all points ${\bf
X}\in{\cal M}$. To this end, define $J_{\mu}^{\cal M}({\bf u})\coloneqq{\rm
E}(F_{\mu}^{\cal M}({\bf X},{\bf u}))$ which, intuitively, provides an
averaged “population ranking” information of ${\bf u}$ when evaluating at each
point in the metric space; in the terminology of sociology, it measures how
“popular” ${\bf u}$ is when voted by all ${\bf X}\in{\cal M}$. As a simple
illustration of the intuition, we simulate i.i.d. samples from the standard
spherical Gaussian in $\mathbb{R}^{2}$ and a von Mises-Fisher (vMF)
distribution in $\mathcal{S}^{2}$ (see Appendix C.2 for details of the vMF
distribution), and we compute $J_{\mu,n}^{\cal M}({\bf
u}):=n^{-1}\sum_{i=1}^{n}F_{\mu,n}^{\cal M}({\bf X}_{i},{\bf u})$, with
$n=1000$, as an estimate of $J_{\mu}^{\cal M}({\bf u})$. In Figure 1 (the
left/right panel is for $\mathbb{R}^{2}$/$\mathcal{S}^{2}$), values of
$J_{\mu,n}^{\cal M}({\bf u})$ of some points are marked in red. Notice that,
in Figure 1, $J_{\mu,n}^{\cal M}({\bf u})$ increases as ${\bf u}$ moves away
from the center. This motivates our definition of global metric quantile which
essentially relies on the ordering of $J_{\mu}^{\cal M}({\bf u})$ for each
${\bf u}\in{\cal M}$. Letting $L\coloneqq\underset{{\bf u}\in{\cal
M}}{\min}J_{\mu}^{\cal M}({\bf u})$ and $U\coloneqq\underset{{\bf u}\in{\cal
M}}{\max}J_{\mu}^{\cal M}({\bf u})$, we make the following assumption.

Figure 1: Plots of samples generated from the standard spherical Gaussian
distribution in $\mathbb{R}^{2}$ (left panel) and the von Mises-Fisher
distribution in $\mathcal{S}^{2}$ (right panel), with estimates of
$J_{\mu}^{\cal M}({\bf u})$ marked in red at some points.

###### Assumption 4

$L\neq U$.

We remark that in the case that $L=U$, the global quantiles may simply be
defined as the local quantiles $q^{\cal M}({\bf u},\tau)$ by choosing any
point ${\bf u}$ on ${\cal M}$, since $J_{\mu}^{\cal M}({\bf u})$ is uniformly
distributed over ${\cal M}$ and any ${\bf u}$ would provide the same global
information. For instance, when ${\cal M}$ is the unit sphere and ${\bf X}$ is
uniformly distributed, one may choose any ${\bf u}\in{\cal M}$ as the $0$th
global quantile and define the $\tau$th global quantile as $q^{\cal M}({\bf
u},\tau)$.

Since $\mu$ is absolutely continuous with positive density $f$ everywhere in
${\cal M}$, $J_{\mu}^{\cal M}({\bf u})$ has a positive density $f_{J}$
everywhere on $[L,U]$. Denoting by $F_{J}$ the distribution function of
$J_{\mu}^{\cal M}({\bf u})\in[L,U]$, then $F_{J}$ is a strict monotonic
increasing function of $J_{\mu}^{\cal M}$. We define the global quantiles as
follows.

###### Definition 4

The $\tau$th global quantile ($\tau\in[0,1]$) of $\mu$ on ${\cal M}$ is

$Q^{\cal M}(\tau)\coloneqq\\{{\bf u}\in{\cal M}:F_{J}(J_{\mu}^{\cal M}({\bf
u}))=\tau\\},\vspace{-3mm}$

the $\tau$th quantile region is

$\bar{Q}^{\cal M}(\tau)\coloneqq\\{{\bf u}\in{\cal M}:F_{J}(J_{\mu}^{\cal
M}({\bf u}))\leq\tau\\},\vspace{-3mm}$

and the $\tau$th inner quantile region is

$\tilde{Q}^{\cal M}(\tau)\coloneqq\\{{\bf u}\in{\cal M}:F_{J}(J_{\mu}^{\cal
M}({\bf u}))<\tau\\}.\vspace{-3mm}$

Similar to the local quantile regions, the global quantile regions are also
nested and their intersection is $0$th global quantile region which is a
compact set of ${\bf u}\in{\cal M}$ that minimizes $J_{\mu}^{\cal M}({\bf
u})$. This minimizer is called metric median, which may be unique or not. For
example, when ${\cal M}=\mathcal{S}^{p}$ and $\mu$ is rotational symmetric
with respect to the pole, the metric median is a parallel or a collection of
parallels. Proposition 6 states the nestedness property of the global quantile
regions. Therefore, the global quantiles induce a center-outward ordering for
the metric space ${\cal M}$. See Appendix B for its proof.

###### Proposition 6

If Assumptions 3 and 4 hold, then for $0\leq\tau_{1}<\tau_{2}\leq 1$,
$\bar{Q}^{\cal M}(\tau_{1})\subsetneq\bar{Q}^{\cal M}(\tau_{2})$.

###  4.2 Empirical global metric quantile

Let $J_{\mu,n}^{\cal M}({\bf u})=n^{-1}\sum_{i=1}^{n}F_{\mu,n}^{\cal M}({\bf
X}_{i},{\bf u})$, which can be considered as an approximation to
$J_{\mu}^{\cal M}({\bf u})\coloneqq{\rm E}(F_{\mu}^{\cal M}({\bf X},{\bf
u}))$, and denote by

$F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}({\bf
u}))\coloneqq\frac{1}{n}\sum_{i=1}^{n}I(J_{\mu,n}^{\cal M}({\bf X}_{i})\leq
J_{\mu,n}^{\cal M}({\bf u}))$

the empirical distribution function of $J_{\mu,n}^{\cal M}({\bf u})$.
Definition of empirical global metric quantiles relies on the ordering of
$J_{\mu,n}^{\cal M}({\bf X}_{i}),i=1,\ldots,n$.

###### Definition 5

The $\tau$th empirical global quantile ($\tau\in[0,1]$) of $\mu$ on ${\cal M}$
is

$Q_{n}^{\cal M}(\tau)\coloneqq\operatorname*{arg\,min}_{{\bf X}_{i}\in{\bf
X}^{(n)}}F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}({\bf X}_{i}))\quad{\rm s.t.}\quad
F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}({\bf X}_{i}))\geq\tau.$

Proposition 7 states that the $\tau$th empirical global quantile, similar to
its local version, is uniformly consistent over $\tau\in[0,1]$. See Appendix B
for its proof.

###### Proposition 7

If Assumptions 1, 3 and 4 holds, then

$\underset{n\rightarrow\infty}{\lim}\underset{\tau\in[0,1]}{\sup}{\rm
P}(Q_{n}^{\cal M}(\tau)\not\subset Q^{\cal M}(\tau))=0.$

Before introducing next property of the empirical global quantile, we first
state some preliminary results of $J_{\mu}^{\cal M}$ and $J_{\mu,n}^{\cal M}$.
Let

$H_{n1}(y)\coloneqq\sqrt{n}\left({\rm P}(J_{\mu,n}^{\cal M}({\bf X}_{1})\leq
y)-\frac{1}{n}\sum_{i=1}^{n}I(J_{\mu,n}^{\cal M}({\bf X}_{i})\leq y)\right)$

and $H_{n2}({\bf u})\coloneqq\sqrt{n}(J_{\mu}^{\cal M}({\bf
u})-J_{\mu,n}^{\cal M}({\bf u})).$ Then we have the following results for
$H_{n1}(y)$ and $H_{n2}({\bf u})$. See Appendix B for its proof.

###### Lemma 1

If Assumption 1 holds, then, as $n\rightarrow\infty$,

$H_{n1}(y)\rightarrow\mathcal{N}(0,F_{J}(y)-(F_{J}(y))^{2}).\vspace{-3mm}$

###### Lemma 2

If Assumption 2 holds, then as $n\rightarrow\infty$,

$H_{n2}({\bf u})\rightarrow\mathcal{N}(0,{\rm Var}(F_{\mu}^{\cal M}({\bf
X},{\bf u}))).\vspace{-3mm}$

Let

$D_{n}(\tau)\coloneqq H_{n1}(J_{\mu,n}^{\cal M}(Q_{n}^{\cal
M}(\tau)))+f_{J}(J_{\mu}^{\cal M}(Q_{n}^{\cal
M}(\tau))\left(H_{n2}(Q_{n}^{\cal M}(\tau))-H_{n2}({\bf X}_{1})\right).$ (2)

Proposition 8 states that the $\tau$th empirical global quantile, similar to
its local version, also lies in a small neighbourhood (with a radius of order
$n^{-1/2}$) of the $\tau$th global quantile contours. See Appendix B for its
proof.

###### Proposition 8

Let Assumptions 1-4 hold. Then for any $\tau\in[0,1]$, with probability one,

$Q_{n}^{\cal M}(\tau)\subset\tilde{Q}^{\cal
M}(\tau^{(n)}+\frac{1}{n})\setminus\tilde{Q}^{\cal M}(\tau^{(n)}),$ (3)

where $\tau^{(n)}=\tau+\frac{1}{\sqrt{n}}D_{n}(\tau)+o_{\rm P}(n^{-1/2}),$ and
$D_{n}(\tau)$ converges to a normal distribution with mean zero.

###  4.3 Global metric rank and sign

The canonical ordering of the real line makes it easy to define ranks and
signs in terms of the sample order. In $\mathbb{R}^{p},p\geq 2$, however, such
ordering does not exist. Using the idea of the measure transportation theory,
Hallin et al. (2021) defined ranks and signs based on a center-outward
ordering of the sample. In our setting of a general metric space $({\cal
M},d)$, we have defined ranks and signs from a local perspective in Section
3.3. From a global perspective, since the global quantile regions relying on
the ordering of $J_{\mu}^{\cal M}({\bf u})$ induce a center-outward ordering
for ${\cal M}$, ranks and signs will naturally be defined based on the
ordering of the empirical version $J_{\mu,n}^{\cal M}({\bf X}_{j}),1\leq j\leq
n,$ of $J_{\mu}^{\cal M}({\bf u})$.

###### Definition 6

The metric rank of ${\bf X}_{j},1\leq j\leq n$ is

$R_{\mu,n}^{\cal M;{\rm Global}}({\bf
X}_{j}):=nF_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}({\bf
X}_{j}))=\sum_{i=1}^{n}I(J_{\mu,n}^{\cal M}({\bf X}_{i})\leq J_{\mu,n}^{\cal
M}({\bf X}_{j})),$

and the metric sign of ${\bf X}_{j}$ is

$S_{\mu,n}^{\cal M;{\rm Global}}({\bf X}_{j}):={\rm
sign}\left(\frac{nF_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}({\bf
X}_{j}))}{n+1}-\frac{1}{2}\right)={\rm sign}\left(\frac{R_{\mu,n}^{\cal M;{\rm
Global}}}{n+1}-\frac{1}{2}\right).$

Proposition 9 states distribution-freeness property of the global metric rank
and sign, as an extension of the corresponding property in the Euclidean space
$(\mathbb{R}^{p},\|\cdot\|)$ (see Proposition 2.5 in Hallin et al. (2021)).
See Appendix B for its proof.

###### Proposition 9

Let $\\{{\bf X}_{1},\ldots,{\bf X}_{n}\\}$ be an i.i.d. sample generated from
the probability measure $\mu$ on ${\cal M}$. Then

  1. (i)

$F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}({\bf
X}^{(n)})):=(F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}({\bf
X}_{1})),F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}({\bf
X}_{2})),\ldots,F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}({\bf X}_{n})))$ is
uniformly distributed over the $n!$ permutations of $(1/n,2/n,\ldots,1)$;

  2. (ii)

$R_{\mu,n}^{\cal M;{\rm Global}}({\bf X}^{(n)}):=(R_{\mu,n}^{\cal M;{\rm
Global}}({\bf X}_{1}),\ldots,R_{\mu,n}^{\cal M;{\rm Global}}({\bf X}_{n}))$ is
uniformly distributed over the $n!$ permutations of $(1,\ldots,n)$;

  3. (iii)

${\rm P}(S_{\mu,n}^{\cal M;{\rm Global}}({\bf X}_{j})=1)=\frac{\left\lfloor
n/2\right\rfloor}{n}={\rm P}(S_{\mu,n}^{\cal M;{\rm Global}}({\bf X}_{j})=-1)$
and ${\rm P}(S_{\mu,n}^{\cal M;{\rm Global}}({\bf
X}_{j})=0)=1-\frac{2\left\lfloor n/2\right\rfloor}{n}$.

###  4.4 Isometry-invariance of the global concepts

Consider the isometry $T:{\cal M}\rightarrow{\cal M}^{\prime}$ defined in
Section 3.4. Similar to their local counterparts, the global quantile, ranks
and signs enjoy the following equivariance properties. See Appendix B for its
proof.

###### Proposition 10

Let $\\{{\bf X}_{1},\ldots,{\bf X}_{n}\\}$ be an i.i.d. sample generated from
the probability measure $\mu$ on ${\cal M}$. Then

  1. (i)

$J_{\mu}^{{\cal M}^{\prime}}(T{\bf u})=J_{\mu}^{{\cal M}}({\bf u})$ and
$J_{\mu,n}^{{\cal M}}(T{\bf u})=J_{\mu,n}^{{\cal M}^{\prime}}({\bf u})$;

  2. (ii)

$Q^{{\cal M}^{\prime}}(\tau)=TQ^{\cal M}(\tau)$ and $Q_{n}^{\cal
M^{\prime}}(\tau)=TQ_{n}^{\cal M}(\tau)$;

  3. (iii)

$R_{\mu,n}^{{\cal M}^{\prime};{\rm Global}}(T{\bf X}_{j})=R_{\mu,n}^{{\cal
M};{\rm Global}}({\bf X}_{j})$ and $S_{\mu,n}^{{\cal M}^{\prime};{\rm
Global}}(T{\bf X}_{j})=S_{\mu,n}^{{\cal M};{\rm Global}}({\bf X}_{j})$ for
$j=1,\ldots,n$.

###  4.5 Relation with depth function

Various types of depth functions have been proposed in order to tackle the
problem of non-canonical ordering in multi-dimensional Euclidean spaces and
non-Euclidean spaces, including halfspace depth (Tukey, 1975), simplicial
depth (Liu, 1990), spatial depth (Serfling, 2002), to name just a few, in
Euclidean space, and halfspace depth (Dai et al., 2022) and depth profiles
(Dubey et al., 2022) in non-Euclidean spaces. In the context of Euclidean
spaces, Zuo and Serfling (2000) formally defined the statistical depth
function which should possess four properties: (i) affine invariance with
respect to some linear transformation; (ii) the depth function is maximized at
the center; (iii) the depth function decreases monotonically along any fixed
ray through the center; (iv) the depth function approaches zero as the point
approaches infinity.

As mentioned in Section 4, our global quantiles hinge on the ordering of
$J_{\mu}^{\cal M}({\bf u})$. Let $\mbox{\boldmath$\theta$}\in{\cal M}$ denote
a point in the metric median $Q^{\cal M}(0)$ of $({\cal M},d)$. Proposition 11
states that under certain conditions of the metric space and the probability
measure, $D_{\mu}^{\cal M}({\bf u}):=1-F_{J}(J_{\mu}^{\cal M}({\bf u}))$ can
be interpreted as a “metric depth” function satisfying the above properties of
a depth function in an Euclidean space. See Appendix B for its proof.

###### Proposition 11

The metric depth function $D_{\mu}^{\cal M}({\bf u})$ satisfies

  1. (i)

$D_{\mu}^{{\cal M}^{\prime}}(T{\bf u})=D_{\mu}^{\cal M}({\bf u})$ under an
isometric transformation $T:{\cal M}\rightarrow{\cal M}^{\prime}$ defined in
Section 4.4;

  2. (ii)

$D_{\mu}^{\cal M}({\bf u})$ attains the maximum value at any
$\mbox{\boldmath$\theta$}\in Q^{\cal M}(0)$;

  3. (iii)

when $({\cal M},d)$ is a geodesic space and the probability measure $\mu$
satisfies $J_{\mu}^{\cal M}(\gamma(t_{1}))\leq J_{\mu}^{\cal
M}(\gamma(t_{2}))$ for any $0\leq t_{1}\leq t_{2}\leq 1$, where
$\gamma:[0,1]\rightarrow{\cal M}$ is an arbitrary geodesic curve starting from
$\theta$, i.e. $\gamma(0)=\mbox{\boldmath$\theta$}\in Q^{\cal M}(0)$, then
$D_{\mu}^{\cal M}(\gamma(t_{2}))\leq D_{\mu}^{\cal M}(\gamma(t_{1}))$;

  4. (iv)

$D_{\mu}^{\cal M}({\bf u})=0$ for any ${\bf u}\in\underset{{\bf v}\in{\cal
M}}{\operatorname*{arg\,max}}J_{\mu}^{\cal M}({\bf v})$.

Suppose $({\cal M},d)$ is the geodesic space as in part (iii) of Proposition
11. Let

$\Gamma_{\gamma(t_{1}),\gamma(t_{2}))}:=\\{{\bf X}\in{\cal M}:d({\bf
X},\gamma(t_{2}))\geq d({\bf X},\gamma(t_{1}))\\}\vspace{-2mm}$

and

$\widetilde{\Gamma}_{\gamma(t_{1}),\gamma(t_{2}))}:=\\{{\bf X}\in{\cal
M}:d({\bf X},\gamma(t_{2}))<d({\bf X},\gamma(t_{1}))\\}\vspace{-2mm}$

be two sets that partition $({\cal M},d)$ according to the distance to
$\gamma(t_{1})$ and $\gamma(t_{2})$. Then the condition in (iii) is equivalent
to

$\int_{\Gamma_{\gamma(t_{1}),\gamma(t_{2}))}}\mu(B({\bf
X},\gamma(t_{2})\setminus B({\bf X},\gamma(t_{1})){\rm
d}\mu\geq\int_{\widetilde{\Gamma}_{\gamma(t_{1}),\gamma(t_{2}))}}\mu(B({\bf
X},\gamma(t_{1})\setminus B({\bf X},\gamma(t_{2})){\rm d}\mu$

for any geodesic curve $\gamma\in{\cal M}$ and any $0\leq t_{1}\leq t_{2}\leq
1$. Loosely speaking, this means that points which are close to the metric
center along a geodesic curve have large densities. This condition holds in an
Euclidean space for, e.g., elliptical distributions with the density function
decreasing monotonically along any fixed ray though the mean.

###  4.6 Computation aspects

We flag that an advantage of our empirical global metirc quantiles (EGMQ) is
that they are easy to implement in computation and computationally efficient,
with a time complexity of $O(n^{2}\log{n})$.222We highlight that the EGMQ is
more computationally efficient than the depth of Dai et al. (2022), of which
the time complexity is $O(n^{3})$. In Appendix F, we provide more detailed
discussion on the computation aspects and algorithm.

###  4.7 Breakdown point of the empirical metric median

The breakdown point of an estimator is the minimal proportion of contamination
in a sample that can makes this estimator arbitrarily bad, and it is a tool
quantifying robustness of this estimator. In this section, we study the
breakdown point of the empirical metric median (EMM), defined as the $0$th
empirical global metric quantile, i.e.,

${\boldsymbol{\theta}}_{n}^{{\bf X}}\coloneqq Q_{n}^{\cal
M}(0)=\operatorname*{arg\,min}_{{\bf X}_{i}\in{\bf X}^{(n)}}J_{\mu,n}^{\cal
M}({\bf X}_{i}).$

In particular, suppose the sample

${\bf Z}^{(m+n)}\coloneqq\\{{\bf X}_{1},\ldots,{\bf X}_{n},{\bf
Y}_{1},\ldots,{\bf Y}_{m}\\}$

contains $m$ contaminated observations ${\bf Y}^{(m)}\coloneqq\\{{\bf
Y}_{1},\ldots,{\bf Y}_{m}\\}$. Let ${\bf Z}_{i},i=1,\ldots,m+n$ be an element
of ${\bf Z}^{(m+n)}$ and denote by $\tilde{F}_{\mu,m+n}^{\mathcal{M}}({\bf
u},{\bf v})$ the EMDF of ${\bf Z}^{(m+n)}$. Let

${\boldsymbol{\theta}}_{m,n}^{{\bf X},{\bf
Y}}\coloneqq\operatorname*{arg\,min}_{{\bf Z}_{i}\in{\bf
Z}^{(m+n)}}\tilde{J}_{\mu,m+n}^{\cal M}({\bf Z}_{i}),$

where $\tilde{J}_{\mu,m+n}^{\cal M}({\bf
u})\coloneqq(m+n)^{-1}\sum_{i=1}^{m+n}\tilde{F}_{\mu,m+n}^{\mathcal{M}}({\bf
Z}_{i},{\bf u})$. Then the finite sample breakdown point of the empirical
metric median is defined as

$\epsilon^{*}_{n}\coloneqq\min_{m}\left\\{\frac{m}{m+n}:\sup_{{\bf
Y}^{(m)}}d({\boldsymbol{\theta}}_{n}^{{\bf
X}},{\boldsymbol{\theta}}_{m,n}^{{\bf X},{\bf Y}})=\infty\right\\},$ (4)

with the convention that $\epsilon^{*}_{n}=1$ if the RHS of (4) is an empty
set (for instance, when ${\cal M}$ is bounded). The following proposition
gives a lower bound of $\epsilon^{*}_{n}$. See Appendix B for the proof.

###### Proposition 12

The finite sample breakdown point of the empirical metric median satisfies

$\epsilon^{*}_{n}\geq\frac{1-n^{-1}\sum_{i=1}^{n}F_{\mu,n}^{\mathcal{M}}({\bf
X}_{i},{\boldsymbol{\theta}}_{n}^{{\bf
X}})}{2-n^{-1}\sum_{i=1}^{n}F_{\mu,n}^{\mathcal{M}}({\bf
X}_{i},{\boldsymbol{\theta}}_{n}^{{\bf X}})}.$ (5)

Consequently, when Assumption 1, 3 and 4 holds, as $n\rightarrow\infty$, the
asymptotic breakdown point
$\epsilon^{*}:=\underset{n\rightarrow\infty}{\lim}\epsilon^{*}_{n}$ satisfies
that with probability one,

$\epsilon^{*}\geq\frac{1-{\rm E}(F_{\mu}^{\mathcal{M}}({\bf
X},{\boldsymbol{\theta}}^{{\bf X}}))}{2-{\rm E}(F_{\mu}^{\mathcal{M}}({\bf
X},{\boldsymbol{\theta}}^{{\bf X}}))},$ (6)

where ${\boldsymbol{\theta}}^{{\bf X}}\coloneqq Q^{\cal
M}(0)=\operatorname*{arg\,min}_{{\bf X}\in{\cal M}}J_{\mu}^{\cal M}({\bf X})$
is the metric median of ${\cal M}$.

###### Remark 4

Proposition 12 implies that the lower bound of $\epsilon^{*}$ depends on the
value of $J_{\mu}^{\cal M}({\boldsymbol{\theta}}^{{\bf X}})={\rm
E}(F_{\mu}^{\mathcal{M}}({\bf X},{\boldsymbol{\theta}}^{{\bf X}}))$: a
distribution with a smaller value of $J_{\mu}^{\cal
M}({\boldsymbol{\theta}}^{{\bf X}})$ has a larger value of the lower bound.
For any symmetric distribution, one can show that ${\rm
E}(F_{\mu}^{\mathcal{M}}({\bf X},{\boldsymbol{\theta}}^{{\bf X}}))<1/2$ when
Assumption 3 holds, and hence this lower bound is always greater than $1/3$,
which is the lower bound of the metric halfspace median (MHM) of Dai et al.
(2022). Table 1 lists the lower bounds of the asymptotic breakdown points
333The asymptotic values are obtained from the empirical counterparts with
$n=1000$.of the EMM and MHM under the spherical Gaussian distribution and
skew-$t_{6}$ distribution in $\mathbb{R}^{2}$, the von Mises-Fisher (vMF) and
tangent vMF distribution in the unit sphere $\mathcal{S}^{2}$, the Wishart
distribution in SPD(3) with degrees of freedom $3$ and scaling matrix
$\begin{pmatrix}1&0.6&0.36\\\ 0.6&1&0.6\\\ 0.36&0.6&1\end{pmatrix};$ see
Section 5 and Appendix C for more details of these distributions. Notice that
the lower bound of the breakdown point of the EMM is uniformly greater than
that of the MHM. For the space of SPD matrices, difference between the EMM and
MHM is more significant, with the value of the EMM close to $0.5$ and the
value of the MHM being $0.2$. This phenomenon of greater robustness of the EMM
than the MHM for the space of SPD matrices is further confirmed via simulation
study in Section 5.2.

Table 1: The lower bounds of the asymptotic breakdown points of the EMM and
MHM under various distributions.

Gaussian skew-$t_{6}$ vMF tangent vMF Wishart EMM 0.42 0.42 0.41 0.42 0.47 MHM
0.33 0.32 0.33 0.32 0.21

##  5 Numerical study

###  5.1 Numerical illustration of the global metric quantile

In this section, we illustrate our concepts of the global quantile and its
empirical version through Monte Carlo experiments on the following metric
spaces; for the sake of conciseness of this section, more details of the
simulation for these metric spaces are deferred to Appendix C. For each
scenario, we generate an i.i.d. sample of size $n$ and plot its empirical
global metric quantiles. The purpose of these experiments is to show
reasonableness of the concepts under various settings and to explore finite-
sample performance of the empirical quantiles. In order to plot $\tau$th
population quantile which is a set of contour, we simulate an i.i.d. sample of
a large size $N$, and we use geom_contour_filled function in the ggplot2
package (Wickham, 2016) to estimate and plot the contour. We flag the small-
sample global quantiles in red triangles in some plots to show consistency of
the sample global quantiles.

  1. (1)

The Euclidean space $\mathbb{R}^{2}$, in which we consider two types of
distributions as follows, and we set $n=500$, $N=10000$.

     * (i)

The spherical Gaussian distribution $\mathcal{N}({\bf 0},{\bf I}_{2})$ (see
Figure D.4 in Appendix D.1).

     * (ii)

Skew-$t_{6}$ distribution (see Figure D.5 in Appendix D.1).

  2. (2)

The unit sphere $\mathcal{S}^{2}$, where three types of distributions on
$\mathcal{S}^{2}$ are considered. We set $n=500$, $N=10000$.

     * (i)

vMF distribution (see Figure D.6 in Appendix D.1).

     * (ii)

tangent vMF distribution. (see the left panel of Figure 2).

     * (iii)

mixture of two vMFs (see Figure D.7 in Appendix D.1).

  3. (3)

The Wasserstein space $W_{2}$ equipped with the Wasserstein distance defined
in equation (A.2) with $p=2$. Here each sample point ${\bf X}_{i}$ is a
Gaussian distribution $\mathcal{N}(0,\sigma_{i}^{2})$ with $\sigma_{i}$ being
generated from the following distributions. We set $n=200$, $N=3000$.
Scatterplots of $\sigma_{i}$ for $i=1,\ldots,N$, the corresponding quantile
contours and the small-sample quantiles are demonstrated in Figures D.8 and
D.9 in Appendix D.1 for the cases (i) and (ii), respectively.

     * (i)

The uniform distribution $U(0,1)$.

     * (ii)

The beta distribution Beta$(2,5)$.

  4. (4)

Space of symmetric positive defintive (SPD) matrices equipped with the affine-
invariant Riemannian metric defined in equation (A.1). Letting ${\bf
X}_{i}=((x_{i},y_{i})^{\top},(y_{i},z_{i})^{\top})$, $x_{i},y_{i},z_{i}$ are
generated from a log-normal distribution. We set $n=500$, $N=3000$.
Scatterplots of $(x_{i},y_{i},z_{i})^{\top}$ and the corresponding metric
quantiles are demonstrated in the right panel of Figure 2.

  5. (5)

The collection of phylogenetic trees equipped with the BHV distance. We
consider the simplest tree space $\mathbb{T}^{3}$ with three leaves and one
interior edges. In our simulation, 80% trees lie on the second branch, and 10%
trees lie on the remaining branch, respectively. We choose $n=500$, $N=12000$.
Figure D.10 in Appendix D.1 presents scatterplots for the random tree
observations and the corresponding metric quantiles.

Figure 2: Left panel: the tangent von Mises-Fisher distribution in the unit
sphere $\mathcal{S}^{2}$. Right panel: space of SPD matrices where each
component of the matrices is generated from a log-normal distribution (each
point in the plot represents the lower diagonal values of a SPD matrix). The
color reflects the level of the global metric quantile.

For the Euclidean space, we observe that the population quantile contours
nicely conform to the shape of the underlying distribution for the spherical
Gaussian and skew-$t_{3}$ cases, where both the skewness and heavy-tails are
presented. Moreover, the empirical global quantiles demonstrate great finite-
sample performance as they all lie close to their population quantiles, which
is consistent with Proposition 7 and Proposition 8.

Similar phenomenon is observed in Figures D.6-D.7 for the unit sphere. For the
Wasserstein space, when the sample is uniform over $(W_{2},d)$ (Figure D.8),
the global metric quantile contours also are nearly center-outward uniformly
distributed; when the sample are skew distributed (Figure D.9), the quantile
contours also present similar pattern of skewness. For the space of SPD
matrices, the right panel of Figure 2 shows a center-outward ordering shape of
the metric quantiles. Regarding the space of phylogenetic trees, we observe
that all the low-levelled quantiles are located on the second branch, and this
is consistent with our simulation setting where 80% trees lie on the second
branch.

###  5.2 Numerical evidence for robustness

In this section, we investigate robustness of the empirical metric median
(EMM) through Monte Carlo experiments. The metric halfspace median (MHM) of
Dai et al. (2022), which was shown to be robust against contamination, and the
estimated transport median (ETM) of Dubey et al. (2022) will be used for
comparison. We consider the Euclidean space, spherical space and the space of
SPD matrices, and for each space, the i.i.d. sample of size $n=100$ is
generated from a “contaminated” distribution $(1-\alpha){\rm P}_{1}+\alpha{\rm
P}_{2}$, where $\alpha\in[0,0.5)$ denotes the proportion of the contamination,
and ${\rm P}_{1}$ and ${\rm P}_{2}$ are as follows.

  1. (i)

The Euclidean space $\mathbb{R}^{3}$. ${\rm P}_{1}$ is the standard spherical
Gaussian distribution $\mathcal{N}(\mathbf{0},\mathbf{I}_{3})$, and ${\rm
P}_{2}$ is the multivariate Cauchy distribution in which each dimension is
sampled from a Cauchy distribution with zero location and unit scale;

  2. (ii)

The spherical space $\mathcal{S}^{2}$. ${\rm P}_{1}$ and ${\rm P}_{2}$ are the
vMF distributions, both with concentration parameter 1, but with different
locations $(1,0,0)^{\top}$ and $(1/\sqrt{3},1/\sqrt{3},1/\sqrt{3})^{\top}$;

  3. (iii)

The space of SPD matrices SPD($3$). ${\rm P}_{1}$ and ${\rm P}_{2}$ are the
Wishart distributions, both with degrees of freedom 3, but with different
scaling matrices $\mathbf{I}_{3}$ and $\begin{pmatrix}1&0.6&0.36\\\
0.6&1&0.6\\\ 0.36&0.6&1\end{pmatrix}.$

In each experiment, we compute the distances of the EMM, MHM and ETM to the
center of ${\rm P}_{1}$. The experiment is repeated 100 times for each metric
space, and we compare robustness of the EMM, MHM and ETM through their
averaged distances to the center of ${\rm P}_{1}$. Plots of the averaged
distances for different levels of $\alpha$ are demonstrated in Figures D.11,
D.12 and D.13 in Appendix D.2 for the simulation schemes (i), (ii) and (iii),
respectively. For the compact metric space $\mathcal{S}^{2}$, the EMM, MHM and
ETM show similar performance. When it comes to the unbounded spaces
$\mathbb{R}^{3}$ and SPD($3$), their differences become more distinct. In
particular, for $\mathbb{R}^{3}$, the MHM is the least robust one, and the EMM
and ETM demonstrate similar robustness. For the SPD($3$), the EMM is the most
robust one, and as $\alpha$ getting close to $0.5$, the gaps between their
averaged distances become much more significant. This is also in consistent
with our analysis of the breakdown points of the EMM and MHM in Table 1.

##  6 Application: metric rank-based independence test

Thanks to the distribution-freeness property, rank-based tests have been
applied quite successfully in Euclidean spaces for various statistical models,
including location (Hodges and Lehmann, 1956), regression models (Jurečková,
1971; Koul, 1971; Hallin et al., 2022a), autoregressive time series (Koul and
Saleh, 1993), non-linear time series (Mukherjee, 2007; Liu and Mukherjee,
2022), to name a few. In a generic metric space, due to lack of concept of
rank, their application has been much less considered. Based on the global
metric rank defined in Section 4.3, we are able to construct of rank-based
tests for a generic metric space. In this section, we illustrate this point by
considering a class of rank-based tests of independence.

###  6.1 Test statistics

Let ${\bf X}\in({\cal M}_{1},d_{1})$ and ${\bf Y}\in({\cal M}_{2},d_{2})$ be
two random variables with distributions satisfying Assumption 3. The problem
of interest is to test the null

$\mathcal{H}_{0}:{\bf X}\,\,\text{and}\,\,{\bf Y}\,\text{are independent}$

based on $n$ independent copies $({\bf X}_{1},{\bf Y}_{1}),\ldots,({\bf
X}_{n},{\bf Y}_{n})$ of $({\bf X},{\bf Y})$. Let $R_{ni}^{{\bf X}}$ and
$R_{ni}^{{\bf Y}}$ denote the global metric ranks of ${\bf X}_{i}$ and ${\bf
Y}_{i}$ among ${\bf X}_{1},\ldots,{\bf X}_{n}$ and ${\bf Y}_{1},\ldots,{\bf
Y}_{n}$, respectively. The rank-based test of independence we consider is
based on the classical linear rank statistic (see, e.g., Sidak et al. (1999,
Chapter 4)), which takes the form

$T^{(n)}_{\varphi_{1},\varphi_{2}}:=\sum_{i=1}^{n}\varphi_{1}\left(\frac{R_{ni}^{{\bf
X}}}{n+1}\right)\varphi_{2}\left(\frac{R_{ni}^{{\bf Y}}}{n+1}\right),$

where $\varphi_{1}:[0,1)\rightarrow\mathbb{R}$ and
$\varphi_{2}:[0,1)\rightarrow\mathbb{R}$ are score functions satisfying the
following traditional assumption.

###### Assumption 5

The score functions $\varphi_{1}$ and $\varphi_{2}$ (i) are square-integrable,
that is, $\int_{0}^{1}\varphi_{\ell}(u){\rm d}u<\infty,\ell=1,2$, and (ii) are
differences of two continuous monotonic increasing functions.

Assumption 5 is quite mild and is satisfied by all square-integrable functions
with bounded variation. The metric rank-based test statistic takes the form

$W^{(n)}_{\varphi_{1},\varphi_{2}}:=(T^{(n)}_{\varphi_{1},\varphi_{2}}-{\rm
E}(T^{(n)}_{\varphi_{1},\varphi_{2}}))/({\rm
Var}(T^{(n)}_{\varphi_{1},\varphi_{2}}))^{1/2},$

where the expectation and variance are taken under $\mathcal{H}_{0}$. In view
of Theorem 6.1.8.1 in Sidak et al. (1999), $W^{(n)}_{\varphi_{1},\varphi_{2}}$
is asymptotically standard normal under $\mathcal{H}_{0}$ as
$n\rightarrow\infty$.

The test statistic $W^{(n)}_{\varphi_{1},\varphi_{2}}$ relies on the choice of
score functions $\varphi_{1}$ and $\varphi_{2}$. Below we provide an example
of a standard score function that is widely employed in the Euclidean space
(see, e.g., Sidak et al. (1999) for the univariate case and Hallin et al.
(2022b) for the multivariate case).

Example (Spearman score). A simple choice is
$\varphi_{1}(u)=u=\varphi_{2}(u)$. The corresponding linear rank statistic is

$T^{(n)}_{\text{Sp}}=\sum_{i=1}^{n}R_{ni}^{{\bf X}}R_{ni}^{{\bf
Y}}/(n+1)^{2}\vspace{-3mm}$

and the test statistic

$W^{(n)}_{\text{Sp}}=\frac{12}{n(n+1)\sqrt{n-1}}\sum_{i=1}^{n}R_{ni}^{{\bf
X}}R_{ni}^{{\bf Y}}-\frac{3(n+1)}{\sqrt{n-1}}\vspace{-3mm}$

upto a scale factor $(n-1)^{-1/2}$, coincides with the the Spearman rank
correlation.

###  6.2 Numerical study of the metric rank-based test

In this section, we investigate via Monte Carlo experiments the finite-sample
performance of the metric rank-based independence test, and we compare our
test with the ball covariance-based (BCov) independence test (Pan et al.,
2019; Wang et al., 2021), and the distance covariance-based (DCov)
independence test (Lyons, 2013). Due to space constraint, we defer the
simulation setting and results to Appendix D.3.

##  7 Real data analysis

In this section, we illustrate the concepts of global and local metric
quantiles through analysis of a real data example, where the global quantile
is used to extract an overall information of the data and the local quantile
enables us to rank subjects according to their similarities to the subject of
our interest (that is, the local quantile center that we chooses).

The Alzheimer’s Disease Neuroimaging Initiative (ADNI) is a multisite study
that aims to improve the prevention and treatment of Alzheimer’s disease (AD).
AD is a neuro-degenerative disease, resulting in the decline of some cognitive
impairments that causes behavioral deficits. Here we focus on an important
brain region: hippocampus, which is typically firstly damaged by AD, leading
to the first clinical manifestations in the form of episodic memory deficits
(Weiner et al., 2013).

We consider the data preprocessed by Kong et al. (2018) that contain left and
right hippocampi of 373 individuals, each of which is characterized by 15,000
radial distances on the left and right hippocampi surfaces, where the radial
distance is defined as the Euclidean distance between the corresponding vertex
on the surface and the medial core of the hippocampus (the left panel of
Figure E.16 in Appendix E illustrates the radial distances, and the right
panel shows the subfields of the left and right hippocampi). The left or right
hippocampi data of an individual can hence be view as a functional data. In
order to capture main variation of the functional curves, as in Kong et al.
(2018), we smooth the functional curves by applying functional principal
component analysis (Ramsay and Silverman, 1997) to left and right surfaces,
respectively. For both the left and right hippocampi, we find the top nine
functional principal components can explain 99% of the total variance.

The metric space for left/right hippocampus is $(L^{2},d_{h})$, where $L^{2}$
is the collection of square integral functions and $d_{h}(u,v)=\|u-v\|_{2}$
for $u,v\in L^{2}$. To jointly consider left and right hippocampi, as in Wang
et al. (2021), we set their product metric space as $(L^{2}\times L^{2},d)$,
where
$d(\mathbf{u},\mathbf{v})=\|(d_{h}(u_{1},v_{1}),d_{h}(u_{2},v_{2}))\|_{2}$ for
$\mathbf{u}=(u_{1},u_{2}),\mathbf{v}=(v_{1},v_{2})\in L^{2}\times L^{2}$.

Plot of the radial distance on the left and right hippocampi surfaces of the
373 individuals is demonstrated in Figure 3, where we mark the empirical
global quantiles at low levels $\tau<0.02$ and high levels
$\tau=0.992,0.995,0.997,1$ with different colors. Most curves distribute
around the low-level quantiles, but quite noticeably, the curves at high
quantile levels have very different shapes. In particular, for the subjects
corresponding to $\tau=0.992$ and $\tau=0.997$, their right hippocampi shrink
at landmarks $5000-8000$; for $\tau=1$, significant shrinkage of the left
hippocampus can be found at landmarks $5000-10000$; for $\tau=0.995$, both the
left and right hippocampi show distinct shrinkage at landmarks $5000-15000$.

It is widely reported that Apolipoprotein E $\epsilon$4 (APOE$\epsilon$4)
shrinks the hippocampus, being a nonnegligible genetic risk factor for AD (Kim
et al., 2009; Jack et al., 2010). Here we perform test of independence of the
APOE$\epsilon$4 and the empirical global quantile levels, based on the
distance covariance of Székely et al. (2007) (implemented in dcov.test
function of R package energy). Consistent with the analysis in Wang et al.
(2021), the test, with the $p$-value $0.01$, is in favour of the dependence
between APOE$\epsilon$4 and the quantile levels.

Next we analyse the data based on the empirical local quantiles, with the
$1$th empirical global quantile being the local quantile center. The empirical
local quantiles at low levels $\tau<0.02$ and high levels
$\tau=0.992,0.995,0.997,1$ are shown in Figure E.17 in Appendix E with
different colors. The low-level local quantiles have similar pattern to the
local center, all of which show obvious shrinkage of the left hippocampi. The
high-level local quantiles, on the contrary, have larger volume of the
hippocampi than most subjects under study.

##  8 Conclusion and discussion

In Euclidean space, quantiles, ranks, and signs are crucial to nonparametric
reasoning. They serve as the foundation for numerous well-known procedures for
testing hypotheses. These test statistics are hence conceptually clear,
computationally efficient, and theoretically beautiful. We introduced local
and global metric quantiles, metric ranks, and metric signs in metric space as
their isometry-invariant counterparts. In addition to exhibiting the desired
theoretical qualities, their empirical counterparts are computationally
efficient. They facilitate the application of conventional nonparametric
statistical inference methods to metric spaces. Consequently, these cutting-
edge concepts open up new research opportunities for metric space-valued data.
For instance, in metric spaces, we can create a distribution-free test of
independence using metric ranks or metric signs. Quantile regression, in which
the covariates and/or the response are measured in metric spaces, is an
additional challenging but fascinating research topic.

Figure 3: Plot of the radial distance on the left (upper panel) and right
(lower panel) hippocampi surfaces for the 373 individuals. The empirical
global quantiles at levels $\tau<0.02$ and $\tau=0.992,0.995,0.997,1$ are
marked with different colors. The $x$-axis represents 15,000 landmarks that
whirlingly surround the hippocampus.

## References

  * Azzalini and Capitanio (2003) Azzalini, A. and Capitanio, A. (2003) Distributions generated by perturbation of symmetry with emphasis on a multivariate skew t-distribution.  Journal of the Royal Statistical Society: Series B (Statistical Methodology), 65, 367–389.
  * Billera et al. (2001) Billera, L. J., Holmes, S. P. and Vogtmann, K. (2001) Geometry of the space of phylogenetic trees.  Advances in Applied Mathematics, 27, 733–767.
  * Chau et al. (2019) Chau, J., Ombao, H. and von Sachs, R. (2019) Intrinsic data depth for hermitian positive definite matrices.  Journal of Computational and Graphical Statistics, 28, 427–439.
  * Dai et al. (2022) Dai, X., Lopez-Pintado, S. and Initiative, A. D. N. (2022) Tukey’s depth for object data.  Journal of the American Statistical Association, 1–13.
  * De Micheaux et al. (2021) De Micheaux, P. L., Mozharovskyi, P. and Vimond, M. (2021) Depth for curve data and applications.  Journal of the American Statistical Association, 116, 1881–1897.
  * Dortet-Bernadet and Wicker (2008) Dortet-Bernadet, J.-L. and Wicker, N. (2008) Model-based clustering on the unit sphere with an illustration using gene expression profiles.  Biostatistics, 9, 66–80.
  * Driemel et al. (2019) Driemel, A., Nusser, A., Phillips, J. M. and Psarros, I. (2019) The vc dimension of metric balls under fréechet and hausdorff distances.  arXiv preprint arXiv:1903.03211.
  * Dryden et al. (2009) Dryden, I. L., Koloydenko, A. and Zhou, D. (2009) Non-euclidean statistics for covariance matrices, with applications to diffusion tensor imaging.  The Annals of Applied Statistics, 3, 1102–1123.
  * Dubey et al. (2022) Dubey, P., Chen, Y. and Müller, H.-G. (2022) Depth profiles and the geometric exploration of random objects through optimal transport.  arXiv preprint arXiv:2202.06117.
  * Frogner et al. (2015) Frogner, C., Zhang, C., Mobahi, H., Araya, M. and Poggio, T. A. (2015) Learning with a wasserstein loss.  Advances in neural information processing systems, 28.
  * García-Portugués et al. (2014) García-Portugués, E., Barros, A. M. G., Crujeiras, R. M., González-Manteiga, W. and Pereira, J. (2014) A test for directional-linear independence, with applications to wildfire orientation and size.  Stoch. Environ. Res. Risk Assess., 28, 1261–1275.
  * García-Portugués et al. (2020) García-Portugués, E., Paindaveine, D. and Verdebout, T. (2020) On optimal tests for rotational symmetry against new classes of hyperspherical distributions.  J. Am. Stat. Assoc., 115, 1873–1887.
  * Haker et al. (2004) Haker, S., Zhu, L., Tannenbaum, A. and Angenent, S. (2004) Optimal mass transport for registration and warping.  International Journal of computer vision, 60, 225–240.
  * Hallin et al. (2021) Hallin, M., Del Barrio, E., Cuesta-Albertos, J. and Matrán, C. (2021) Distribution and quantile functions, ranks and signs in dimension d: A measure transportation approach.  The Annals of Statistics, 49, 1139–1165.
  * Hallin et al. (2022a) Hallin, M., Hlubinka, D. and Hudecová, Š. (2022a) Efficient fully distribution-free center-outward rank tests for multiple-output regression and manova.  Journal of the American Statistical Association, 1–17.
  * Hallin et al. (2022b) Hallin, M., La Vecchia, D. and Liu, H. (2022b) Center-outward r-estimation for semiparametric varma models.  Journal of the American Statistical Association, 117, 925–938.
  * Hodges and Lehmann (1956) Hodges, J. L. and Lehmann, E. L. (1956) The efficiency of some nonparametric competitors of the t-test.  The Annals of Mathematical Statistics, 324–335.
  * Jack et al. (2010) Jack, C. R., Knopman, D. S., Jagust, W. J., Shaw, L. M., Aisen, P. S., Weiner, M. W., Petersen, R. C. and Trojanowski, J. Q. (2010) Hypothetical model of dynamic biomarkers of the alzheimer’s pathological cascade.  The Lancet Neurology, 9, 119–128.
  * Jung et al. (2010) Jung, S., Liu, X., Marron, J. and Pizer, S. M. (2010) Generalized pca via the backward stepwise approach in image analysis.  In Brain, Body and Machine, 111–123. Springer.
  * Jurečková (1971) Jurečková, J. (1971) Nonparametric estimate of regression coefficients.  The Annals of Mathematical Statistics, 1328–1338.
  * Kim et al. (2009) Kim, J., Basak, J. M. and Holtzman, D. M. (2009) The role of apolipoprotein e in alzheimer’s disease.  Neuron, 63, 287–303.
  * Kong et al. (2018) Kong, D., Ibrahim, J. G., Lee, E. and Zhu, H. (2018) Flcrm: Functional linear cox regression model.  Biometrics, 74, 109–117.
  * Koul (1971) Koul, H. L. (1971) Asymptotic behavior of a class of confidence regions based on ranks in regression.  The Annals of Mathematical Statistics, 466–476.
  * Koul and Saleh (1993) Koul, H. L. and Saleh, A. M. E. (1993) R-estimation of the parameters of autoregressive [ar (p)] models.  The Annals of Statistics, 534–551.
  * Li et al. (2013) Li, P., Wang, Q. and Zhang, L. (2013) A novel earth mover’s distance methodology for image matching with gaussian mixture models.  In Proceedings of the IEEE International Conference on Computer Vision, 1689–1696.
  * Liu and Mukherjee (2022) Liu, H. and Mukherjee, K. (2022) R-estimators in garch models: asymptotics and applications.  The Econometrics Journal, 25, 98–113.
  * Liu (1990) Liu, R. Y. (1990) On a notion of data depth based on random simplices.  The Annals of Statistics, 405–414.
  * Liu and Singh (1992) Liu, R. Y. and Singh, K. (1992) Ordering directional data: concepts of data depth on circles and spheres.  Ann. Stat., 20, 1468–1484.
  * Lyons (2013) Lyons, R. (2013) Distance covariance in metric spaces.  The Annals of Probability, 41, 3284–3305.
  * Marinucci and Peccati (2011) Marinucci, D. and Peccati, G. (2011) Random Fields on the Sphere.  London Mathematical Society Lecture Note Series. Cambridge: Cambridge University Press.
  * Marinucci et al. (2008) Marinucci, D., Pietrobon, D., Balbi, A., Baldi, P., Cabella, P., Kerkyacharian, G., Natoli, P., Picard, D. and Vittorio, N. (2008) Spherical needlets for cosmic microwave background data analysis.  Mon. Not. R. Astron. Soc., 383, 539–545.
  * Mukherjee (2007) Mukherjee, K. (2007) Generalized r-estimators under conditional heteroscedasticity.  Journal of Econometrics, 141, 383–415.
  * Pan et al. (2019) Pan, W., Wang, X., Zhang, H., Zhu, H. and Zhu, J. (2019) Ball covariance: A generic measure of dependence in banach space.  Journal of the American Statistical Association.
  * Pandolfo et al. (2018) Pandolfo, G., Paindaveine, D. and Porzio, G. C. (2018) Distance-based depths for directional data.  Can. J. Stat., 46, 593–609.
  * Petersen et al. (2021) Petersen, A., Liu, X. and Divani, A. A. (2021) Wasserstein $f$-tests and confidence bands for the fréchet regression of density response curves.  The Annals of Statistics, 49, 590–611.
  * Ramsay and Silverman (1997) Ramsay, J. and Silverman, B. W. (1997) Functional data analysis (Springer series in statistics).  Springer, New York, NY.
  * Rubner et al. (2000) Rubner, Y., Tomasi, C. and Guibas, L. J. (2000) The earth mover’s distance as a metric for image retrieval.  International journal of computer vision, 40, 99–121.
  * Serfling (2002) Serfling, R. (2002) A depth function and a scale curve based on spatial quantiles.  In Statistical data analysis based on the L1-norm and related methods, 25–38. Springer.
  * Sidak et al. (1999) Sidak, Z., Sen, P. K. and Hajek, J. (1999) Theory of rank tests.  Elsevier.
  * Smith et al. (2013) Smith, S. M., Vidaurre, D., Beckmann, C. F., Glasser, M. F., Jenkinson, M., Miller, K. L., Nichols, T. E., Robinson, E. C., Salimi-Khorshidi, G., Woolrich, M. W., Barch, D. M., Uugurbil, K. and Essen, D. C. V. (2013) Functional connectomics from resting-state fmri.  Trends in Cognitive Sciences, 17, 666 – 682.  Special Issue: The Connectome.
  * Székely et al. (2007) Székely, G. J., Rizzo, M. L. and Bakirov, N. K. (2007) Measuring and testing dependence by correlation of distances.  The annals of statistics, 35, 2769–2794.
  * Tukey (1975) Tukey, J. W. (1975) Mathematics and the picturing of data.  In Proceedings of the International Congress of Mathematicians, Vancouver, 1975, vol. 2, 523–531.
  * Van der Vaart (2000) Van der Vaart, A. W. (2000) Asymptotic statistics, vol. 3.  Cambridge university press.
  * van der Vaart and Wellner (1996) van der Vaart, A. W. and Wellner, J. A. (1996) Weak convergence.  In Weak convergence and empirical processes, 16–28. Springer.
  * Villani (2009) Villani, C. (2009) Optimal transport: old and new, vol. 338.  Springer.
  * Wang et al. (2021) Wang, X., Zhu, J., Pan, W., Zhu, J. and Zhang, H. (2021) Nonparametric statistical inference via metric distribution function in metric spaces.  arXiv preprint arXiv:2107.07317.
  * Weiner et al. (2013) Weiner, M. W., Veitch, D. P., Aisen, P. S., Beckett, L. A., Cairns, N. J., Green, R. C., Harvey, D., Jack, C. R., Jagust, W., Liu, E., Morris, J. C., Petersen, R. C., Saykin, A. J., Schmidt, M. E., Shaw, L., Shen, L., Siuciak, J. A., Soares, H., Toga, A. W. and Trojanowski, J. Q. (2013) The alzheimer’s disease neuroimaging initiative: A review of papers published since its inception.  Alzheimer’s & Dementia, 9, e111–e194.
  * Wickham (2016) Wickham, H. (2016) ggplot2: elegant graphics for data analysis.  springer.
  * Woese (2002) Woese, C. R. (2002) On the evolution of cells.  Proceedings of the National Academy of Sciences, 99, 8742–8747.
  * Zhu et al. (2021) Zhu, J., Pan, W., Zheng, W. and Wang, X. (2021) Ball: An r package for detecting distribution difference and association in metric spaces.  Journal of Statistical Software, 97, 1–31.
  * Zuo and Serfling (2000) Zuo, Y. and Serfling, R. (2000) General notions of statistical depth function.  Annals of statistics, 461–482.

Appendices.

##  Appendix A Some preliminaries

###  A.1 Examples of metric spaces

Here we list some examples of non-Euclidean metric spaces that have wide
applications in various fields.

###### Example 1

Unit hypersphere $\mathcal{S}^{p-1}:=\\{{\bf x}\in\mathbb{R}^{p}:{\bf
x}^{\top}{\bf x}=1\\}$ equipped with the geodesic distance $d({\bf x},{\bf
y})=\cos^{-1}({\bf x}^{\top}{\bf y})$ for ${\bf x},{\bf
y}\in\mathcal{S}^{p-1}$. This type of data is usually referred to as
directional data, which has applications in astronomy (Marinucci et al.,
2008), environmetrics (García-Portugués et al., 2014), genetics (Dortet-
Bernadet and Wicker, 2008), image analysis (Jung et al., 2010), and so on.

###### Example 2

The manifold of $p\times p$ symmetric positive definite matrices, denoted by
${\rm SPD}(p)$, equipped with the geodesic distance

$d({\bf X},{\bf Y}):=\|{\rm logm}({\bf X}^{-1/2}{\bf Y}{\bf X}^{-1/2})\|_{\rm
F}$ (A.1)

for ${\bf X},{\bf Y}\in{\rm SPD}(p)$, where $\|\cdot\|_{\rm F}$ is the
Frobenius norm and ${\rm logm}$ is the matrix logarithm. Applications of SPD
matrix include diffusion tensor image (Dryden et al., 2009) and brain
connectivity analysis (Smith et al., 2013).

###### Example 3

The collection of phylogenetic trees with $p$ leaves, denoted by
$\mathbb{T}^{p}$, equipped with the Billera-Holmes-Vogtmann (BHV) distance;
see Billera et al. (2001) for details. The phylogenetic trees space can be
used for analysing evolutionary relationship between species (Woese, 2002).

###### Example 4

Wasserstein space ${\cal W}_{p}$ is the space of probability measures that
have finite moment of order $p$ (Villani, 2009). Let $\Gamma(P,Q)$ be the
collection of all probability measures on ${\cal M}\times{\cal M}$ with
marginal $P$ and $Q$. Then $({\cal W}_{p},d)$ is a metric space when equipped
with the Wasserstein metric

$d({\rm P},{\rm Q}):=\left(\inf_{\gamma\in\Gamma({\rm P},{\rm Q})}\int\|{\bf
x}-{\bf y}\|^{p}{\rm d}\gamma({\bf x},{\bf y})\right)^{1/p},$ (A.2)

where ${\bf x}\sim{\rm P}$ and ${\bf y}\sim{\rm Q}$. Wasserstein metric is
widely employed to compare distributions of two random variables, and it has
applications in image retrieval (Rubner et al., 2000; Li et al., 2013), image
registration (Haker et al., 2004), machine learning (Frogner et al., 2015),
and so on.

###### Example 5

Given $K$ metric spaces $({\cal M}_{k},d_{k}),k=1,\ldots,K$, let ${\cal
M}=\prod_{k=1}^{K}{\cal M}_{k}$ and $d$ be a metric constructed from $d_{k}$
yields the product metric space $({\cal M},d)$. In particular, $d$ may be
constructed as follows: for any two vectors ${\bf
u}=(u_{1},\ldots,u_{k})^{\top}$ and ${\bf v}=(v_{1},\ldots,v_{k})^{\top}$ in
${\cal M}$, we may define

$d({\bf u},{\bf
v}):=\left(\sum_{k=1}^{K}(d_{k}(u_{k},v_{k}))^{p}\right)^{1/p},\ p\geq 1$

and verify that $d(\cdot,\cdot)$ is a metric on ${\cal M}$. See Section 7 for
a real-data example.

###  A.2 The Glivenko-Cantelli and Donsker properties of the EMDF

Under the entropy condition in Assumption 1, the empirical metric distribution
function enjoys the following Glivenko-Cantelli property.

######  Proposition 13 (Glivenko-Cantelli)

If Assumption 1 holds, then

$\underset{n\rightarrow\infty}{\lim}\underset{{\bf u},{\bf v}\in{\cal
M}}{\sup}|F_{\mu}^{\cal M}({\bf u},{\bf v})-F_{\mu,n}^{\cal M}({\bf u},{\bf
v})|=0,\quad{\rm a.s.}.$

The Donsker property of the empirical metric distribution function are stated
as follows.

######  Proposition 14 (Donsker)

If Assumption 2 holds, then $\\{\mathbb{G}_{\mu,n}^{\cal M}({\bf u},{\bf
v}):{\bf u},{\bf v}\in{\cal M}\\}$ converges in distribution to a Gaussian
process $\\{\mathbb{G}_{\mu}^{\cal M}({\bf u},{\bf v}):{\bf u},{\bf v}\in{\cal
M}\\}$, with mean zero and the covariance

$\mu(\bar{B}({\bf u}_{1},d({\bf u}_{1},{\bf v}_{1}))\cap\bar{B}({\bf
u}_{2},d({\bf u}_{2},{\bf v}_{2})))-F_{\mu}^{\cal M}({\bf u}_{1},{\bf
v}_{1})F_{\mu}^{\cal M}({\bf u}_{2},{\bf v}_{2}).$

##  Appendix B Proofs

Proof of Proposition 1. For any ${\bf x}\in\bar{q}^{\cal M}({\bf
u},\tau_{1})$, noting that $F_{\mu}^{\cal M}({\bf u},{\bf
x})\leq\tau_{1}<\tau_{2}$, we have ${\bf x}\in\bar{q}^{\cal M}({\bf
u},\tau_{2})$. Since $\mu$ is absolutely continuous with positive density $f$
everywhere in ${\cal M}$, there exists ${\bf x}\in{\cal M}$ such that

${\bf x}\in\\{{\bf v}\in{\cal M}:\tau_{1}<F_{\mu}^{\cal M}({\bf u},{\bf
v})\leq\tau_{2}\\}.$

The result follows.

$\square$

Proof of Proposition 2. For $\tau\in[0,\frac{1}{n})$, the result is trivial.
Now for $\tau\in[\frac{1}{n},1]$, note that

$\displaystyle F_{\mu}^{\cal M}({\bf u},q_{n}^{\cal M}({\bf
u},\tau))=F_{\mu,n}^{\cal M}({\bf u},q_{n}^{\cal M}({\bf
u},\tau))+\frac{1}{\sqrt{n}}\mathbb{G}_{\mu,n}^{\cal M}({\bf u},q_{n}^{\cal
M}({\bf u},\tau)),$

where, by definition of $q_{n}^{\cal M}({\bf u},\tau)$, $F_{\mu,n}^{\cal
M}({\bf u},q_{n}^{\cal M}({\bf u},\tau))\in[\tau,\tau+\frac{1}{n})$ with
probability one since $\mu$ is absolutely continuous with positive density $f$
everywhere in ${\cal M}$. Hence, with probability one,

$F_{\mu}^{\cal M}({\bf u},q_{n}^{\cal M}({\bf
u},\tau))\in[\tau+\frac{1}{\sqrt{n}}\mathbb{G}_{\mu,n}^{\cal M}({\bf
u},q_{n}^{\cal M}({\bf
u},\tau)),\tau+\frac{1}{n}+\frac{1}{\sqrt{n}}\mathbb{G}_{\mu,n}^{\cal M}({\bf
u},q_{n}^{\cal M}({\bf u},\tau))).$

The result then follows from the definition of $\tilde{q}^{\cal M}({\bf
u},\tau)$.

$\square$

Proof of Proposition 3. Proposition 13 entails that

$\displaystyle\underset{{\bf u}\in{\cal M},\tau\in[0,1]}{\sup}|F_{\mu}^{\cal
M}({\bf u},q_{n}^{\cal M}({\bf u},\tau))-F_{\mu}^{\cal M}({\bf u},q^{\cal
M}({\bf u},\tau))|$ $\displaystyle=$ $\displaystyle\underset{{\bf u}\in{\cal
M},\tau\in[0,1]}{\sup}|F_{\mu,n}^{\cal M}({\bf u},q_{n}^{\cal M}({\bf
u},\tau))-\tau|+o_{\rm P}(1)<\frac{1}{n}+o_{\rm P}(1),$

where the last inequality follows from that $F_{\mu,n}^{\cal M}({\bf
u},q_{n}^{\cal M}({\bf u},\tau))\in[\tau,\tau+\frac{1}{n})$ with probability
one for any ${\bf u}\in{\cal M}$ and $\tau\in[0,1]$. The result then follows
from the definition of the local quantile $q^{\cal M}({\bf u},\tau)$.

$\square$

Proof of Proposition 4. Part (i) follows from that $\\{{\bf X}_{1},\ldots,{\bf
X}_{n}\\}$ are i.i.d.. Part (ii) and (iii) follow directly from part (i).

$\square$

Proof of Proposition 5. Part (i) follows directly from the definitions of
$F_{\mu}^{\cal M}({\bf u},{\bf v})$ and $F_{\mu,n}^{\cal M}({\bf u},{\bf v})$.
Part (ii) and (iii) follow directly from part (i) and the definitions of the
local quantile, rank and sign.

$\square$

Proof of Proposition 6. For any ${\bf x}\in\bar{Q}^{\cal M}(\tau_{1})$, since
$F_{J}(J_{\mu}^{\cal M}({\bf x}))\leq\tau_{1}<\tau_{2}$, we have ${\bf
x}\in\bar{Q}^{\cal M}(\tau_{2})$. Moreover, since, under Assumption 3,
$f_{J}>0$ for any $J_{\mu}^{\cal M}({\bf u})\in[L,U]$, there exists ${\bf
x}\in{\cal M}$ such that $F_{J}(J_{\mu}^{\cal M}({\bf
x}))\in(\tau_{1},\tau_{2}]$. The result follows.

$\square$

Proof of Proposition 7. First note that

$\displaystyle\underset{{\bf u}\in{\cal M}}{\sup}|J_{\mu}^{\cal M}({\bf
u})-J_{\mu,n}^{\cal M}({\bf u})|$ $\displaystyle\leq\underset{{\bf u}\in{\cal
M}}{\sup}|J_{\mu}^{\cal M}({\bf u})-n^{-1}\sum_{i=1}^{n}F_{\mu}^{\cal M}({\bf
X}_{i},{\bf u})|+\underset{{\bf u}\in{\cal
M}}{\sup}|n^{-1}\sum_{i=1}^{n}F_{\mu}^{\cal M}({\bf X}_{i},{\bf
u})-J_{\mu,n}^{\cal M}({\bf u})|$ $\displaystyle=0,\quad{\rm a.s.}$ (B.1)

as $n\rightarrow\infty$ due to the SLLN and Proposition 13.

By the SLLN, for any $u\in{\cal M}$,

$|F_{J}(J_{\mu}^{\cal M}({\bf u}))-\frac{1}{n}\sum_{i=1}^{n}I(J_{\mu}^{\cal
M}({\bf X}_{i})\leq J_{\mu}^{\cal M}({\bf u}))|=0,\quad{\rm a.s.}$

as $n\rightarrow\infty$. Hence, for any $u\in{\cal M}$,

$|F_{J}(J_{\mu}^{\cal M}({\bf u}))-F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}({\bf
u}))|\leq o_{\rm P}(1)+|A_{n1}({\bf u})|,$

where

$A_{n1}({\bf u})\coloneqq\frac{1}{n}\sum_{i=1}^{n}I(J_{\mu}^{\cal M}({\bf
X}_{i})\leq J_{\mu}^{\cal M}({\bf
u}))-\frac{1}{n}\sum_{i=1}^{n}I(J_{\mu,n}^{\cal M}({\bf X}_{i})\leq
J_{\mu,n}^{\cal M}({\bf u})).$

Note that

$\displaystyle\underset{{\bf u}\in{\cal M}}{\sup}{\rm P}(|A_{n1}({\bf
u})|>\epsilon)$ $\displaystyle\leq\epsilon^{-1}\underset{{\bf u}\in{\cal
M}}{\sup}{\rm E}|A_{n1}({\bf u})|$
$\displaystyle\leq\epsilon^{-1}\underset{{\bf u}\in{\cal
M}}{\sup}\frac{1}{n}\sum_{i=1}^{n}{\rm E}|I(J_{\mu}^{\cal M}({\bf X}_{i})\leq
J_{\mu}^{\cal M}({\bf u}))-I(J_{\mu,n}^{\cal M}({\bf X}_{i})\leq
J_{\mu,n}^{\cal M}({\bf u}))|$ $\displaystyle=\epsilon^{-1}\underset{{\bf
u}\in{\cal M}}{\sup}{\rm E}|I(J_{\mu}^{\cal M}({\bf X}_{1})\leq J_{\mu}^{\cal
M}({\bf u}))-I(J_{\mu,n}^{\cal M}({\bf X}_{1})\leq J_{\mu,n}^{\cal M}({\bf
u}))|$ $\displaystyle=\epsilon^{-1}\underset{{\bf u}\in{\cal
M}}{\sup}\left\\{[{\rm P}(J_{\mu}^{\cal M}({\bf X}_{1})\leq a_{1})-{\rm
P}(J_{\mu}^{\cal M}({\bf X}_{1})\leq a_{2})]{\rm P}(a_{1}\geq a_{2})\right.$
$\displaystyle\hskip 56.9055pt\left.+[{\rm P}(J_{\mu}^{\cal M}({\bf
X}_{1})\leq a_{2})-{\rm P}(J_{\mu}^{\cal M}({\bf X}_{1})\leq a_{1})]{\rm
P}(a_{1}<a_{2})\right\\},$

where $a_{1}=J_{\mu}^{\cal M}({\bf u})$ and $a_{2}=J_{\mu,n}^{\cal M}({\bf
u})+J_{\mu}^{\cal M}({\bf X}_{1})-J_{\mu,n}^{\cal M}({\bf X}_{1})$, say.
Hence, we have

$\displaystyle\underset{{\bf u}\in{\cal M}}{\sup}{\rm P}(|A_{n1}({\bf
u})|>\epsilon)$ $\displaystyle\leq\epsilon^{-1}\underset{{\bf u}\in{\cal
M}}{\sup}2|{\rm P}(J_{\mu}^{\cal M}({\bf X}_{1})\leq a_{1})-{\rm
P}(J_{\mu}^{\cal M}({\bf X}_{1})\leq a_{2})|$
$\displaystyle=\epsilon^{-1}\underset{{\bf u}\in{\cal M}}{\sup}2|{\rm
P}(J_{\mu}^{\cal M}({\bf X}_{1})\leq J_{\mu}^{\cal M}({\bf u}))$
$\displaystyle\qquad\qquad-{\rm P}(J_{\mu}^{\cal M}({\bf X}_{1})\leq
J_{\mu}^{\cal M}({\bf u})+J_{\mu,n}^{\cal M}({\bf u})-J_{\mu}^{\cal M}({\bf
u})+J_{\mu}^{\cal M}({\bf X}_{1})-J_{\mu,n}^{\cal M}({\bf X}_{1}))|$
$\displaystyle\leq\epsilon^{-1}\underset{{\bf v}\in{\cal M}}{\sup}f_{J}(J({\bf
v}))\underset{{\bf u}\in{\cal M}}{\sup}4|J_{\mu,n}^{\cal M}({\bf
u})-J_{\mu}^{\cal M}({\bf u})|\rightarrow 0$

as $n\rightarrow\infty$ due to (B.1) and that $f_{J}$ is bounded as implied by
Assumption 4. Therefore,

$\underset{n\rightarrow\infty}{\lim}\underset{\tau\in[0,1]}{\sup}{\rm
P}(|F_{J}(J_{\mu}^{\cal M}(Q_{n}^{\cal
M}(\tau)))-F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}(Q_{n}^{\cal
M}(\tau)))|>\epsilon)=0$

for any $\epsilon>0$. Finally, by noticing that
$F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}(Q_{n}^{\cal
M}(\tau)))\in[\tau,\tau+\frac{1}{n})$ with probability one, we have

$\underset{n\rightarrow\infty}{\lim}\underset{\tau\in[0,1]}{\sup}{\rm
P}(|F_{J}(J_{\mu}^{\cal M}(Q_{n}^{\cal M}(\tau)))-\tau|>\epsilon)=0.$

The result thus follows from the definition of the global quantile $Q^{\cal
M}(\tau)$.

$\square$

Proof of Lemma 1. By Theorem 19.3 in Van der Vaart (2000), we have

$\left[{\rm P}(J_{\mu,n}^{\cal M}({\bf X}_{1})\leq y)-({\rm P}(J_{\mu,n}^{\cal
M}({\bf X}_{1})\leq
y))^{2}\right]^{-1/2}H_{n1}(y)\rightarrow\mathcal{N}(0,1).$ (B.2)

It follows from the Fatou’s Lemma and (B.1) that

$\underset{n\rightarrow\infty}{\lim}\underset{u\in{\cal M}}{\sup}{\rm
P}(J_{\mu}^{\cal M}({\bf u})\neq J_{\mu,n}^{\cal M}({\bf u}))=0,$

which entails that

$\underset{n\rightarrow\infty}{\lim}\underset{y\in\mathbb{R}}{\sup}|{\rm
P}(J_{\mu,n}^{\cal M}({\bf X}_{1})\leq y)-{\rm P}(J_{\mu}^{\cal M}({\bf
X}_{1})\leq y)|=0.$

This, combined with (B.2), yields the result.

$\square$

Proof of Lemma 2. Decomposing $H_{n2}({\bf u})$ yields $H_{n2}({\bf
u})=A_{n2}({\bf u})+A_{n3}({\bf u})$, where

$\displaystyle A_{n2}({\bf u})$
$\displaystyle\coloneqq\frac{1}{n}\sum_{i=1}^{n}\sqrt{n}(F_{\mu}^{\cal M}({\bf
X}_{i},{\bf u})-F_{\mu,n}^{\cal M}({\bf X}_{i},{\bf u}))$
$\displaystyle=\frac{1}{n}\sum_{i=1}^{n}\mathbb{G}_{\mu,n}^{\cal M}({\bf
X}_{i},{\bf u})$

and

$A_{n3}({\bf u})\coloneqq\sqrt{n}\left({\rm E}(F_{\mu}^{\cal M}({\bf X},{\bf
u}))-\frac{1}{n}\sum_{i=1}^{n}F_{\mu}^{\cal M}({\bf X}_{i},{\bf u})\right).$

Note that, under Assumption 2, $A_{n2}({\bf u})=O_{\rm P}(n^{-1/2})$ since
$\\{\mathbb{G}_{\mu,n}^{\cal M}({\bf X}_{i},{\bf u});1\leq i\leq n\\}$
converges to a Gaussian process and ${\bf X}_{1},\ldots,{\bf X}_{n}$ are
independent. By the CLT, as $n\rightarrow\infty$,

$A_{n3}({\bf u})\rightarrow\mathcal{N}(0,{\rm Var}(F_{\mu}^{\cal M}({\bf
X},{\bf u}))).$

The result then follows.

$\square$

Proof of Proposition 8. First note that

$\displaystyle F_{J}(J_{\mu}^{\cal M}(Q_{n}^{\cal
M}(\tau)))-F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}(Q_{n}^{\cal M}(\tau)))$
$\displaystyle=$ $\displaystyle F_{J}(J_{\mu}^{\cal M}(Q_{n}^{\cal
M}(\tau)))-{\rm E}[I(J_{\mu,n}^{\cal M}({\bf X}_{1})\leq J_{\mu,n}^{\cal
M}(Q_{n}^{\cal M}(\tau)))]$ $\displaystyle\qquad+{\rm E}[I(J_{\mu,n}^{\cal
M}({\bf X}_{1})\leq J_{\mu,n}^{\cal M}(Q_{n}^{\cal
M}(\tau)))]-\frac{1}{n}\sum_{i=1}^{n}I(J_{\mu,n}^{\cal M}({\bf X}_{i})\leq
J_{\mu,n}^{\cal M}(Q_{n}^{\cal M}(\tau)))$ $\displaystyle=$
$\displaystyle\frac{1}{\sqrt{n}}A_{n4}(\tau)+\frac{1}{\sqrt{n}}H_{n1}(J_{\mu,n}^{\cal
M}(Q_{n}^{\cal M}(\tau))),$ (B.3)

where

$\displaystyle A_{n4}(\tau)$
$\displaystyle\coloneqq\sqrt{n}\\{F_{J}(J_{\mu}^{\cal M}(Q_{n}^{\cal
M}(\tau)))-{\rm E}[I(J_{\mu,n}^{\cal M}({\bf X}_{1})\leq J_{\mu,n}^{\cal
M}(Q_{n}^{\cal M}(\tau)))]\\}$ $\displaystyle=\sqrt{n}\\{{\rm P}(J_{\mu}^{\cal
M}({\bf X}_{1})\leq J_{\mu}^{\cal M}(Q_{n}^{\cal M}(\tau)))-{\rm
P}(J_{\mu,n}^{\cal M}({\bf X}_{1})\leq J_{\mu,n}^{\cal M}(Q_{n}^{\cal
M}(\tau)))\\}$ $\displaystyle=\sqrt{n}\int_{J_{\mu}^{\cal M}({\bf
X}_{1})-J_{\mu,n}^{\cal M}({\bf X}_{1})+J_{\mu,n}^{\cal M}(Q_{n}^{\cal
M}(\tau))}^{J_{\mu}^{\cal M}(Q_{n}^{\cal M}(\tau))}{\rm d}F_{J}$
$\displaystyle=f_{J}(z)(H_{n2}(Q_{n}^{\cal M}(\tau))-H_{n2}({\bf X}_{1})),$
(B.4)

with $z$ being a point in the closed interval of $J_{\mu}^{\cal M}({\bf
X}_{1})-J_{\mu,n}^{\cal M}({\bf X}_{1})+J_{\mu,n}^{\cal M}(Q_{n}^{\cal
M}(\tau))$ and $J_{\mu}^{\cal M}(Q_{n}^{\cal M}(\tau))$. Here (B.4) follows
from continuity of $f_{J}$ as implied by Assumption 3. By (B.1), we moreover
have

$\underset{\tau\in[0,1]}{\sup}|f_{J}(z)-f_{J}(Q_{n}^{\cal
M}(\tau))|=0,\quad{\rm a.s.}$ (B.5)

as $n\rightarrow\infty$. Piecing together (2), (B.3), (B.4) and (B.5) yields

$\underset{\tau\in[0,1]}{\sup}\left|\sqrt{n}\left(F_{J}(J_{\mu}^{\cal
M}(Q_{n}^{\cal M}(\tau)))-F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}(Q_{n}^{\cal
M}(\tau)))\right)-D_{n}(\tau)\right|=0,\quad{\rm a.s.}$

as $n\rightarrow\infty$. Then (3) follows from that, with probability one,

$F_{J_{n}}^{(n)}(J_{\mu,n}^{\cal M}(Q_{n}^{\cal
M}(\tau)))\in[\tau,\tau+\frac{1}{n})$

due to definition of $Q_{n}^{\cal M}(\tau)$.

Finally, the asymptotic normality of $D_{n}(\tau)$ follows from Lemma 1 and
Lemma 2.

$\square$

Proof of Proposition 9. Part (i) follows from that $\\{{\bf X}_{1},\ldots,{\bf
X}_{n}\\}$ are i.i.d.. Part (ii) and (iii) follow directly from part (i).

$\square$

Proof of Proposition 10. Part (i) follows from Proposition 5 (i). Part (ii)
and (iii) follow immediately from part (i) and the definitions of the global
quantile, rank and sign.

$\square$

Proof of Proposition 11. Part (i) follows directly from Proposition 10. Part
(ii) follows from the definition of $D_{\mu}^{\cal M}({\bf u})$. Part (iii)
follows from the fact that $J_{\mu}^{\cal M}(\gamma(t_{1}))\leq J_{\mu}^{\cal
M}(\gamma(t_{2}))$ implies $F_{J}(J_{\mu}^{\cal M}(\gamma(t_{1})))\leq
F_{J}(J_{\mu}^{\cal M}(\gamma(t_{2})))$. Part (iv) follows from
$F_{J}(J_{\mu}^{\cal M}({\bf u}))=1$ for any ${\bf u}\in\underset{{\bf
v}\in{\cal M}}{\operatorname*{arg\,max}}J_{\mu}^{\cal M}({\bf v})$.

$\square$

Proof of Proposition 12. In order to prove (5),it is sufficient to study the
case that ${\cal M}$ is unbounded since $\epsilon^{*}_{n}=1$ by convention if
${\cal M}$ is bounded.Note that in order to obtain supremum of
$d({\boldsymbol{\theta}}_{n}^{{\bf X}},{\boldsymbol{\theta}}_{m,n}^{{\bf
X},{\bf Y}})$, the contamination points ${\bf Y}^{(m)}$ should stay far away
from ${\bf X}^{(n)}$. In particular, $\sup_{{\bf
Y}^{(m)}}d({\boldsymbol{\theta}}_{n}^{{\bf
X}},{\boldsymbol{\theta}}_{m,n}^{{\bf X},{\bf Y}})$ is obtained when $d({\bf
X}_{i},{\bf Y}_{j})=\infty,\forall i\in\\{1,\ldots,n\\},j\in\\{1,\ldots,m\\}$,
which entails $\tilde{F}_{\mu,m+n}^{\mathcal{M}}({\bf X}_{i},{\bf Y}_{j})=1$.
Therefore, by definition of $\tilde{J}_{\mu,m+n}^{\cal M}(\cdot)$, we have

$\tilde{J}_{\mu,m+n}^{\cal M}({\bf
X}_{i})=\frac{m}{m+n}+\frac{1}{m+n}\sum_{j=1}^{n}\tilde{F}_{\mu,m+n}^{\mathcal{M}}({\bf
X}_{j},{\bf X}_{i})$ (B.6)

and

$\tilde{J}_{\mu,m+n}^{\cal M}({\bf
Y}_{j})=\frac{n}{m+n}+\frac{1}{m+n}\sum_{\ell=1}^{m}\tilde{F}_{\mu,m+n}^{\mathcal{M}}({\bf
Y}_{\ell},{\bf Y}_{j}).$ (B.7)

Noticing that ${\boldsymbol{\theta}}_{n}^{{\bf X}}\in{\bf X}^{(n)}$, in order
to reach supremum of $d({\boldsymbol{\theta}}_{n}^{{\bf
X}},{\boldsymbol{\theta}}_{m,n}^{{\bf X},{\bf Y}})$, we must have
${\boldsymbol{\theta}}_{m,n}^{{\bf X},{\bf Y}}\in{\bf Y}^{(m)}$ since ${\bf
Y}^{(m)}$ can be arbitrarily chosen to make $d({\boldsymbol{\theta}}_{n}^{{\bf
X}},{\boldsymbol{\theta}}_{m,n}^{{\bf X},{\bf Y}})$ large. We hence have

$\min_{{\bf Y}_{j}\in{\bf Y}^{(m)}}\tilde{J}_{\mu,m+n}^{\cal M}({\bf
Y}_{j})\leq\min_{{\bf X}_{i}\in{\bf X}^{(n)}}\tilde{J}_{\mu,m+n}^{\cal M}({\bf
X}_{i}).$ (B.8)

Moreover, noticing that $\tilde{J}_{\mu,m+n}^{\cal M}({\bf Y}_{j})$ in (B.7)
can reach its minimum value $\frac{n}{m+n}$ when ${\bf Y}_{j}={\bf
Y}_{\ell},\forall j,\ell\in\\{1,\ldots,m\\}$ (since then
$\sum_{\ell=1}^{m}\tilde{F}_{\mu,m+n}^{\mathcal{M}}({\bf Y}_{\ell},{\bf
Y}_{j})=0$). Therefore, piecing together (B.6), (B.7) and (B.8) yields

$\displaystyle\frac{n}{m+n}$
$\displaystyle\leq\frac{m}{m+n}+\frac{1}{m+n}\min_{{\bf X}_{j}\in{\bf
X}^{(n)}}\sum_{i=1}^{n}\tilde{F}_{\mu,m+n}^{\mathcal{M}}({\bf X}_{j},{\bf
X}_{i})$
$\displaystyle=\frac{m}{m+n}+\frac{1}{m+n}\sum_{j=1}^{n}F_{\mu,n}^{\mathcal{M}}({\bf
X}_{j},{\boldsymbol{\theta}}_{n}^{{\bf X}}),$ (B.9)

where the last equality follows from $\tilde{F}_{\mu,m+n}^{\mathcal{M}}({\bf
X}_{j},{\bf X}_{i})=F_{\mu,n}^{\mathcal{M}}({\bf X}_{j},{\bf X}_{i})$ when
$d({\bf X}_{i},{\bf Y}_{j})=\infty,\forall
i\in\\{1,\ldots,n\\},j\in\\{1,\ldots,m\\}$, and the definition of
${\boldsymbol{\theta}}_{n}^{{\bf X}}$. Finally, (B.9) yields

$m\geq n-\sum_{j=1}^{n}F_{\mu,n}^{\mathcal{M}}({\bf
X}_{j},{\boldsymbol{\theta}}_{n}^{{\bf X}}),$

which entails the desired result in (5).

Finally, (6) follows from (5), Proposition 13 and Proposition 7.

$\square$

##  Appendix C Simulation settings for various metric spaces

Below we give details of the simulation settings for various metric spaces
considered in Section 5.

###  C.1 The Euclidean space $\mathbb{R}^{2}$

  * (i)

The spherical Gaussian distribution $\mathcal{N}({\bf 0},{\bf I}_{2})$.

  * (ii)

Mixture of three Gaussian distributions

$\frac{3}{8}{\cal
N}(\mbox{\boldmath$\mu$}_{1},\mbox{\boldmath$\Sigma$}_{1})+\frac{3}{8}{\cal
N}(\mbox{\boldmath$\mu$}_{2},\mbox{\boldmath$\Sigma$}_{2})+\frac{1}{4}{\cal
N}(\mbox{\boldmath$\mu$}_{3},\mbox{\boldmath$\Sigma$}_{3}),$

with $\mbox{\boldmath$\mu$}_{1}=(-3,0)^{\top},\
\mbox{\boldmath$\mu$}_{2}=(3,0)^{\top},\
\mbox{\boldmath$\mu$}_{3}=(0,-2.5)^{\top}$ and

$\mbox{\boldmath$\Sigma$}_{1}=\begin{pmatrix}5&-4\vspace{-1mm}\\\
-4&5\vspace{-1mm}\end{pmatrix},\
\mbox{\boldmath$\Sigma$}_{2}=\begin{pmatrix}5&4\vspace{-1mm}\\\
4&5\vspace{-1mm}\end{pmatrix},\
\mbox{\boldmath$\Sigma$}_{3}=\begin{pmatrix}4&0\vspace{-1mm}\\\
0&1\vspace{-1mm}\end{pmatrix}.$

  * (iii)

Skew-$t_{6}$ distribution. The $d$-dimensional skew-$t_{\nu}$ distribution
($\nu$ denotes the degree of freedom) has density

$\displaystyle f({\bf
z};\mbox{\boldmath$\xi$},\mbox{\boldmath$\Sigma$},{\mbox{\boldmath$\alpha$\unboldmath}},\nu)$
$\displaystyle:=\,$ $\displaystyle 2{\rm
det}({\mbox{\boldmath$w$\unboldmath})}^{-1}t_{d}({\bf
x};\mbox{\boldmath$\Sigma$},\nu)T\left({\mbox{\boldmath$\alpha$\unboldmath}}^{\prime}{\bf
x}\big{(}{{(\nu+d)}/{(\nu+{\bf x}^{\prime}\mbox{\boldmath$\Sigma$}^{-1}{\bf
x})}}\big{)}^{1/2};\nu+d\right),\quad\\!\\!\\!{\bf z}\in{\mathbb{R}}^{d},$

(see Azzalini and Capitanio (2003)) where ${\bf
x}={\mbox{\boldmath$w$\unboldmath}}^{-1}({\bf z}-\mbox{\boldmath$\xi$})$;
${\mbox{\boldmath$w$\unboldmath}}=\left({\rm
diag}(\mbox{\boldmath$\Sigma$})\right)^{1/2}$,
$\mbox{\boldmath$\xi$}\in{\mathbb{R}}^{d}$, and
${\mbox{\boldmath$\alpha$\unboldmath}}\in{\mathbb{R}}^{d}$ are scale,
location, and shape parameters respectively, $T(y;\nu)$ denotes the univariate
$t_{\nu}$ distribution function, and

$t_{d}({\bf
x};\mbox{\boldmath$\Sigma$},\nu):=\frac{\Gamma((\nu+d)/2)}{(\nu\pi)^{d/2}\Gamma(\nu/2){\rm
det}(\mbox{\boldmath$\Sigma$})^{1/2}}\left(1+\frac{{\bf
x}^{\prime}{\mbox{\boldmath$w$\unboldmath}}\mbox{\boldmath$\Sigma$}^{-1}{\mbox{\boldmath$w$\unboldmath}}{\bf
x}}{\nu}\right)^{-(\nu+d)/2},\quad{\bf x}\in{\mathbb{R}}^{d}.\vspace{-2mm}$

Here we set $d=2$, $\nu=6$, $\mbox{\boldmath$\xi$}={\bf 0}$,
${\mbox{\boldmath$\alpha$\unboldmath}}=(5,2)^{\top}$, and
$\mbox{\boldmath$\Sigma$}=\begin{pmatrix}7&4\vspace{-1mm}\\\
4&5\vspace{-1mm}\end{pmatrix}$.

###  C.2 The unit sphere $\mathcal{S}^{2}$

Three types of distributions on $\mathcal{S}^{2}$ are considered:

  1. (i)

von Mises-Fisher (vMF) distribution. A random vector ${\bf X}$ has a vMF
distribution if the density is ${\bf x}\mapsto c_{p,\kappa}\exp(\kappa{\bf
x}^{\top}\mbox{\boldmath$\mu$})$, where
$\mbox{\boldmath$\mu$}\in\mathcal{S}^{p-1}$, $\kappa>0$ and $c_{p,\kappa}$ are
the location, concentration parameters and normalizing constant, respectively;
we write ${\bf X}\sim\mathcal{M}_{p}(\mbox{\boldmath$\mu$},\kappa)$. We set
$\kappa=20$ and $\mbox{\boldmath$\mu$}=(0,0,1)^{\top}$ in the simulation.

  2. (ii)

tangent vMF distribution as in García-Portugués et al. (2020). A random vector
${\bf X}$ has a tangent vMF distribution with location $\mu$, angular function
$G$, skewness direction $\omega$, skewness intensity $\kappa$ iff ${\bf X}$
has the same distribution as

$V\mbox{\boldmath$\mu$}+\sqrt{1-V^{2}}{\bf\Gamma}_{\mbox{\boldmath$\mu$}}{\bf
U},$ (C.1)

where $V\sim G$ is independent of ${\bf
U}\sim\mathcal{M}_{p-1}({\mbox{\boldmath$\omega$\unboldmath}},\kappa)$ and
where ${\bf\Gamma}_{\mbox{\boldmath$\mu$}}$ is an arbitrary $p\times(p-1)$
matrix whose columns form an orthonormal basis of the orthogonal complement of
$\mu$ (hence
${\bf\Gamma}_{\mbox{\boldmath$\mu$}}^{\top}{\bf\Gamma}_{\mbox{\boldmath$\mu$}}={\bf
I}_{p-1}$ and
${\bf\Gamma}_{\mbox{\boldmath$\mu$}}{\bf\Gamma}_{\mbox{\boldmath$\mu$}}^{\top}={\bf
I}_{p}-\mbox{\boldmath$\mu$}\mbox{\boldmath$\mu$}^{\top}$). In the simulation,
we set $\mbox{\boldmath$\mu$}=(0,0,1)^{\top}$,
${\mbox{\boldmath$\omega$\unboldmath}}=(0.7,\sqrt{0.51})^{\top}$, $\kappa=10$
and $V\sim 2\tilde{V}-1$, where $\tilde{V}$ is generated from the beta
distribution ${\rm Beta}(2,8)$.

  3. (iii)

mixture of two vMFs: the distribution is given by

$I(U\leq 0.3){\bf Z}_{1}+I(U>0.3){\bf Z}_{2},$

where $U\sim{\rm U}[0,1]$, ${\bf
Z}_{1}\sim\mathcal{M}_{p}(\mbox{\boldmath$\mu$}_{1},\kappa_{1})$ and ${\bf
Z}_{2}\sim\mathcal{M}_{p}(\mbox{\boldmath$\mu$}_{2},\kappa_{2})$ are mutually
independent. We set $\kappa_{1}=\kappa_{2}=50$,
$\mbox{\boldmath$\mu$}_{1}=(0,-1,1)^{\top}$ and
$\mbox{\boldmath$\mu$}_{2}=(0,1,1)^{\top}$ in the simulation.

###  C.3 The Wasserstein space $W_{2}$

We consider the Wasserstein space $W_{2}$ equipped with the Wasserstein
distance in (A.2) with $p=2$, in which each sample point ${\bf
X}_{i},i=1,\ldots,n$ is a Gaussian distribution
$\mathcal{N}(0,\sigma_{i}^{2})$ with $\sigma_{i}$ being generated from the
uniform distribution $U(0,1)$ (Figure D.8) and the beta distribution
Beta$(2,5)$ (Figure D.9). In each Figure, we show scatterplots of $\sigma_{j}$
for $j=1,\ldots,N$ and the corresponding quantile contours are obtained from
the large sample of size $N=3000$.

###  C.4 Space of symmetric positive defintive matrices

We consider space of symmetric positive defintive (SPD) matrices $\mathcal{S}$
equipped with the affine-invariant Riemannian metric

$d({\bf X},{\bf Y}):=\|{\rm logm}({\bf X}^{-1/2}{\bf Y}{\bf X}^{-1/2})\|_{\rm
F}$

for ${\bf X},{\bf Y}\in{\rm SPD}(p)$. We generate the random sample from
$2\times 2$ space of SPD matrices. Letting ${\bf
X}_{i}=((x_{i},y_{i})^{\top},(y_{i},z_{i})^{\top})$, we generate
$x_{i},y_{i},z_{i}$ from a log-normal distribution. Scatterplots of
$(x_{i},y_{i},z_{i})^{\top}$ and the corresponding metric quantiles are
demonstrated in Figure LABEL:fig:spd_log_normal.

###  C.5 Space of phylogenetic trees

The collection of phylogenetic trees equipped with the BHV distance is a
metric space. We illustrate the geometry of the simplest tree space
$\mathbb{T}^{3}$ with three leaves and one interior edges. The topology of the
tree is the way leaves and interior nodes are connected. There are three
bifurcating tree topologies, respectively, corresponding to which of leaf
branches out first. The three legs of the spider correspond to three different
bifurcating tree topologies, and the position of a point on a leg corresponds
to the length of the interior edge. Tree space $\mathbb{T}^{3}$ is represented
by the $(\mathbb{R}^{+},0,0)\cup(0,\mathbb{R}^{+},0)\cup(0,0,\mathbb{R}^{+})$.
For example, a point $(b,0,0)$ in the tree space represents a tree whose
interior node lying on the first branch at a distance $b$ from the origin.

In our simulation, 80% tree lies on the second branch, and 10% tree lies on
the remaining branch, respectively. $\\{b_{i};i=1,\ldots,n\\}$ is i.i.d.
sampled from the Beta$(2,2)$ distribution. Scatterplots of random tree
observations and the corresponding metric quantile are demonstrated in Figure
D.10.

##  Appendix D Supplementary material for numerical study

###  D.1 Additional numerical results of Section 5.1

This section provides some numerical results of Section 5. Global metric
quantiles of the spherical Gaussian distribution and of the skew-$t_{6}$
distribution are shown in Figures D.4 and D.5, respectively. Figures D.6 and
D.7 are for the vMF and mixture of two vMFs in $\mathcal{S}^{2}$,
respectively. Quantiles for the Wasserstein space are demonstrated in Figures
D.8 and D.9 for the cases (3)(i) and (ii), respectively. Quantiles for the
tree space are shown in Figure D.10.

Figure D.4: The Euclidean space $\mathbb{R}^{2}$: the spherical Gaussian
distribution. The empirical global quantiles for sample size $n=500$ are
flagged in red triangles. Figure D.5: The Euclidean space $\mathbb{R}^{2}$:
the skew-$t_{6}$ distribution. The empirical global quantiles for sample size
$n=500$ are marked in red triangles. Figure D.6: The unit sphere
$\mathcal{S}^{2}$: the von Mises-Fisher distribution. The empirical global
quantiles for sample size $n=500$ are marked in red triangles. Figure D.7: The
unit sphere $\mathcal{S}^{2}$: the mixture of two von Mises-Fisher
distributions. The empirical global quantiles for sample size $n=500$ are
marked in red triangles. Figure D.8: The Wasserstein space $W_{2}$. Each
sample point $X_{i},i=1,\ldots,n$ is a Gaussian distribution
$\mathcal{N}(0,\sigma_{i}^{2})$ where $\sigma_{i}$ follows the uniform
distribution $U(0,1)$. The upper panel shows the density of $U(0,1)$, and the
lower panel is the plot of the global metric quantiles. Figure D.9: The
Wasserstein space $W_{2}$. Each sample point $X_{i},i=1,\ldots,n$ is a
Gaussian distribution $\mathcal{N}(0,\sigma_{i}^{2})$ where $\sigma_{i}$
follows the Beta$(2,5)$ distributions. The upper panel shows the density of
the Beta$(2,5)$ distribution, and the lower panel is the plot of the global
metric quantiles. Figure D.10: Space of phylogenetic trees $\mathbb{T}^{3}$:
each tree has a component following the Beta(2, 2) distribution and the other
components being zeros. Each point represents one tree in space of
phylogenetic trees. The color reflects the value of the global metric
quantile.

###  D.2 Additional numerical results of Section 5.2

This section provides additional numerical results of Section 5.2. Figures
D.11 and D.12 show Averaged distances of the EMM, MHM and ETM to the center of
${\rm P}_{1}$ for the Euclidean space $\mathbb{R}^{3}$ and for the spherical
space $\mathcal{S}^{2}$, respectively.

Figure D.11: Averaged distances of the EMM, MHM and ETM to the center of ${\rm
P}_{1}$ for the Euclidean space $\mathbb{R}^{3}$. Figure D.12: Averaged
distances of the EMM, MHM and ETM to the center of ${\rm P}_{1}$ for the
spherical space $\mathcal{S}^{2}$.  Figure D.13: Averaged distances of the
EMM, MHM and ETM to the center of ${\rm P}_{1}$ for the space of $3\times 3$
SPD matrices.

###  D.3 Simulation setting and numerical results of Section 6.2

In order to investigate the finite-sample performance of the metric rank-based
independence test, we simulate $n$ independent copies $({\bf X}_{1},{\bf
Y}_{1}),\ldots,({\bf X}_{n},{\bf Y}_{n})$ by letting

${\bf Y}_{i}=(k{\bf X}_{i}+0.8\mbox{\boldmath$\epsilon$}_{i}+0.5{\bf
I}_{2})(k{\bf X}_{i}+0.8\mbox{\boldmath$\epsilon$}_{i}+0.5{\bf
I}_{2})^{\prime},i=1,\ldots,n,$

where $k$ is a positive value, ${\bf X}_{i}$ is generated from the bivariate
spherical Gaussian distribution ${\cal N}({\bf 0},{\bf I}_{2})$, and
$\mbox{\boldmath$\epsilon$}_{i}$, independent of ${\bf X}_{i}$, is generated
from ${\cal N}({\bf 0},{\bf I}_{2})$ or the bivariate Cauchy distribution.
Hence, ${\bf X}$ is in the Euclidean space and ${\bf Y}$ is in the space of
SPD matrices.

The rejection rates of the Spearman metric rank-based, BCov and DCov tests at
$5\%$ nominal level for different values of $k$ are shown in Figure D.14 in
Appendix D.3, where the left-panel corresponds to the case that
$\mbox{\boldmath$\epsilon$}_{i}$ is generated from the Gaussian distribution
and the right-panel is for the Cauchy distribution. For both distributions,
all the tests have rejection rates close to the nominal level when ${\bf X}$
and ${\bf Y}$ are independent (that is, $k=0$). All the tests have similar
power under the Gaussian distribution. Under the Cauchy distribution, however,
the Spearman and BCov tests have similar rejection rates, both of which are
significant greater than that of the DCov test. This illustrates robustness of
the Spearman and BCov tests (the BCov test is robust since it is constructed
from the metric distribution function).

Next, we compare rejection rates of these tests by fixing $k$ and changing the
sample size $n$. For the Gaussian distribution of
$\mbox{\boldmath$\epsilon$}_{i}$, we set $k=0.8$, and the results are shown in
the left panel of Figure D.15 in Appendix D.3; for the Cauchy distribution, we
set $k=2$, and the results are given in the right panel of Figure D.15. For
both distributions, rejection rates of all the tests get close to one as $n$
increases. As in Figure D.14, the Spearman and BCov tests have similar
performance, and they both have rejection rates remarkably greater than the
DCov test.

We highlight that in addition to the great finite-sample performance, our
metric rank-based test is also computationally more efficient than the BCov
and DCov tests. Specifically, our test has complexity of $O(n^{2}\log(n))$. In
contrast, the BCov and DCov tests use $R$ times permutations replications to
approximate the distribution under the null hypothesis, having complexities
$O(Rn^{2}\log(n))$ and $O(Rn^{2})$, respectively. Thus, the proposed test is
more computationally attractive than the benchmarked independence tests for
metric-valued data.

Figure D.14: The rejection rates of the Spearman metric rank-based, BCov and
DCov tests for the spherical normal distribution (left-panel) and Cauchy
distribution (right-panel) of $\mbox{\boldmath$\epsilon$}_{i}$ for different
values of $k$. The red line represents the nominal level.

Figure D.15: The rejection rates of the Spearman metric rank-based, BCov and
DCov tests for the spherical normal distribution (left-panel) and Cauchy
distribution (right-panel) of $\mbox{\boldmath$\epsilon$}_{i}$ for different
values of the sample size $n$. The red line represents the nominal level.

##  Appendix E Supplementary material for the real data

This section provides some additional results for the real data analysis in
Section 7. Figure E.16 illustrates the medial core, radial distance, order of
15,000 landmarks, and the hippocampal subfields on the each hippocampus
surface. Figure E.17 shows the radial distance on the left (upper panel) and
right (lower panel) hippocampi surfaces for the 373 individuals, where the
empirical local quantiles at levels $\tau<0.02$ and $\tau=0.992,0.995,0.997,1$
are marked with different colors.

Figure E.16: Left panel: visualization for medial core, radial distance, and
the order of 15,000 landmarks on the each hippocampus surface. Right panel:
hippocampal subfields, where CA and Sub are abbreviations for cornu amonis and
subiculum, respectively. Figure E.17: Plot of the radial distance on the left
(upper panel) and right (lower panel) hippocampi surfaces for the 373
individuals. The empirical local quantiles at levels $\tau<0.02$ and
$\tau=0.992,0.995,0.997,1$ are marked with different colors (the local
quantile center is the $1$th emprical global quantile). The $x$-axis
represents 15,000 landmarks that whirlingly surround the hippocampus.

##  Appendix F Algorithm for computing empirical metric distribution function

From the definition of the EGMQ in Definition 5, computing the EGMQ can be
divided into three steps and computation in each step is straightforward: (i)
compute the empirical metric distribution function on
$(\mathbf{X}_{i},\mathbf{X}_{j})$ for $i,j=1,\ldots,n$ which yields a $n\times
n$ matrix
$\mathbf{F}^{(n)}:=F_{\mu,n}^{\mathcal{M}}(\mathbf{X}_{i},\mathbf{X}_{j})$;
(ii) compute the column-wise mean of $\mathbf{F}^{(n)}$ to obtain values of
$J_{\mu,n}^{\mathcal{M}}(\mathbf{X}_{1}),\ldots,J_{\mu,n}^{\mathcal{M}}(\mathbf{X}_{n})$;
(iii) compute the empirical quantiles of
$J_{\mu,n}^{\mathcal{M}}(\mathbf{X}_{1}),\ldots,J_{\mu,n}^{\mathcal{M}}(\mathbf{X}_{n})$,
which are the EGMQ of $\mathbf{X}_{1},\ldots,\mathbf{X}_{n}$.

Here we describe an efficient procedure of computing the EGMQ, which has a
time complexity of $O(n^{2}\log{n})$. Notice that naïvely compute (i), (ii),
(iii) have complexities of $O(n^{3})$, $O(n^{2})$ and $O(n\log{n})$,
respectively. Therefore, to mitigate the computational burden, the primary
work is to reduce the time complexity of (i). Actually, by leveraging the
Algorithm 1 proposed by Zhu et al. (2021), we can directly reduce the time
complexity of (i) from $O(n^{3})$ to $O(n^{2}\log{n})$; the overall
computation procedure hence will have complexity of $O(n^{2}\log{n})$. More
specifically, notice that $nF_{\mu,n}^{\cal M}({\bf X}_{i},{\bf
X}_{j}),i,j=1,\ldots,n$ is the rank of $d_{ij}:=d({\bf X}_{i},{\bf X}_{j})$
among the $i$th row of the pairwise distance matrix ${\bf
D}^{(n)}:=(d_{ij})_{i,j=1,\ldots,n}$. Since computing the rank matrix
$\mathbf{R}^{(n)}:=(r_{ij})_{i,j=1,\ldots,n}$, obtained by ranking ${\bf
D}^{(n)}$ row by row, is of $O\left(n^{2}\log n\right)$ time complexity,
computational complexity of ${\bf F}^{(n)}:=(F_{\mu,n}^{\cal M}({\bf
X}_{i},{\bf X}_{j}))_{i,j=1,\ldots,n}$ can be reduced from $O(n^{3})$ (if
$F_{\mu,n}^{\cal M}({\bf X}_{i},{\bf X}_{j})$ is computed from the definition
in (1)) to $O\left(n^{2}\log n\right)$. Below we summarize the algorithm for
computing ${\bf F}^{(n)}$ in Algorithm 1.

1

Input: An i.i.d. sample ${\bf X}^{(n)}=\left\\{{\bf X}_{1},\ldots,{\bf
X}_{n}\right\\}$.

Output: The $n\times n$ matrix of the empirical metric distribution function
${\bf F}^{(n)}=(F_{\mu,n}^{\cal M}({\bf X}_{i},{\bf X}_{j}))_{i,j=1,\ldots,n}$

2 for  _$i\leftarrow 1$ to $n$_ do

3 for  _$j\leftarrow 1$ to $n$_ do

4 $d_{ij}\leftarrow d({\bf X}_{i},{\bf
X}_{j}),r_{ij}\leftarrow\sum_{k=1}^{n}I(d_{ij}\leq d_{ik})$

5 end for

6

7 end for

8Set $\mathbf{R}^{(n)}:=(r_{ij})_{i,j=1,\ldots,n}$ and ${\bf
F}^{(n)}=n^{-1}\mathbf{R}^{(n)}$.

Algorithm 1 Algorithm for computing the empirical metric distribution function