wasserstein | R Documentation |
This function will calculate exact or approximate Wasserstein distances between two groups of observations. Please note that this function will likely be deprecated in favor of using the native function from the approxOT
package.
wasserstein(
X,
Y,
p = 2,
ground_p = 2,
observation.orientation = c("rowwise", "colwise"),
method = c("exact", "sinkhorn", "greenkhorn", "hilbert", "rank",
"univariate.approximation", "univariate.approximation.pwr", "univariate"),
...
)
X |
Matrix for first group |
Y |
Matrix for second group |
p |
Power of the Wasserstein distance |
ground_p |
Power of the distance metric. Usually same as |
observation.orientation |
Are observations unique by rows or columns? One of "colwise" or "rowwise" |
method |
One of the outputs of |
... |
additional options for sinkhorn based methods. |
A numeric value
if(rlang::is_installed("stats")) {
n <- 128
p <- 10
x <- matrix( stats::rnorm( p * n ), nrow = n, ncol = p )
y <- matrix( stats::rnorm( p * n ), nrow = n, ncol = p )
dist <- wasserstein(x,y, p = 2, ground_p = 1, observation.orientation = "rowwise",
method = "hilbert") #fast
print(dist)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.