Trimmed Mallows Distance Between Two Vectors
Source:R/mallows-distance.R
mallows_distance_trimmed.Rd
Calculate the trimmed \(p^{\text{th}}\) Mallows distance of two vectors, also known as the trimmed Wasserstein-\(p\) distance.
Arguments
- vec1
A numeric vector.
- vec2
A numeric vector of the same length as
vec1
.- p
A number \(\geq 1\) for the \(p^{\text{th}}\) Mallows distance. Default is 2.
- alpha
a trimming parameter in \([0, 0.5)\). If
alpha
=0 (default), there is no trimming and result is just the Mallows distance.
Details
Calculate the trimmed \(p^{\text{th}}\) Mallows distance of two vectors, also known as the trimmed Wasserstein-\(p\) distance between two samples of the same size.
Say \(X_i \overset{\text{iid}}{\sim} F\) and \(Y_j \overset{\text{iid}}{\sim} G\). Let \(\hat{F}(x) = \sum_i\boldsymbol{1}(X_i \leq x)\) and \(\hat{F}^{-1}(t) = \text{inf}\{x : \hat{F}(x) \leq t\}\). Define \(\hat{G}(y)\) and \(\hat{G}^{-1}(t)\) similarly.
Let \(\alpha\in[0,0/5)\) be a trimming parameter.
Then the trimmed \(p^{\text{th}}\) Mallows distance between \(\hat{F}(x)\) and \(\hat{G}(t)\) is
\(\Psi_{\alpha, p}(\hat{F}, \hat{G}) = \left( \frac{1}{1-2\alpha}\int_{\alpha}^{1-\alpha} |\hat{F}^{-1}(t) - \hat{G}^{-1}(t) |^p dt \right)^{1/p}\)
References
Mallows CL (1972). “A note on asymptotic joint normality.” The Annals of Mathematical Statistics, 508--515.
Munk A, Czado C (1998). “Nonparametric validation of similar distributions and assessment of goodness of fit.” Journal of the Royal Statistical Society Series B: Statistical Methodology, 60(1), 223--241.
Examples
library(igraph)
data("karate")
set.seed(1)
boot.sample <- bootstrap_latent_space(karate, d = 2, B = 1)
#> This graph was created by an old(er) igraph version.
#> Call upgrade_graph() on it to use with the current igraph version
#> For now we convert it on the fly...
orig.degree <- get_centrality(karate, "degree")
boot.degree <- get_centrality(boot.sample[[1]], "degree")
mallows_distance(orig.degree, boot.degree)
#> [1] 1.608799
mallows_distance_trimmed(orig.degree, boot.degree, alpha = 1/34)
#> [1] 1.699609
mallows_distance_trimmed(orig.degree, boot.degree, alpha = 2/34)
#> [1] 1.51804