# wasserstein: Calculate Wasserstein distances In WpProj: Linear p-Wasserstein Projections

 wasserstein R Documentation

## Calculate Wasserstein distances

### Description

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.

### Usage

``````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"),
...
)
``````

### Arguments

 `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 `p` `observation.orientation` Are observations unique by rows or columns? One of "colwise" or "rowwise" `method` One of the outputs of `transport_options()` `...` additional options for sinkhorn based methods. `epsilon` and `niter` determining the hyperparameters for the negative entropy penalty

A numeric value

### Examples

``````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)
}
``````

WpProj documentation built on May 29, 2024, 7:55 a.m.