# squared_wass_approx: Compute approximated squared 2-Wasserstein distance In goncalves-lab/waddR: Statistical tests for detecting differential distributions based on the 2-Wasserstein distance

 squared_wass_approx R Documentation

## Compute approximated squared 2-Wasserstein distance

### Description

Calculates an approximated squared 2-Wasserstein distance based on the mean squared difference between 1000 equidistant quantiles corresponding to the empirical distributions of two input vectors `x` and `y`

### Usage

``````squared_wass_approx(x, y)
``````

### Arguments

 `x` sample (vector) representing the distribution of condition `A` `y` sample (vector) representing the distribution of condition `B`

### Value

The approximated squared 2-Wasserstein distance between `x` and `y`

### References

Schefzik, R., Flesch, J., and Goncalves, A. (2020). waddR: Using the 2-Wasserstein distance to identify differences between distributions in two-sample testing, with application to single-cell RNA-sequencing data.

See the functions `wasserstein_metric` and `squared_wass_decomp` for alternative implementations of the 2-Wasserstein distance

### Examples

``````set.seed(24)
x<-rnorm(100)
y1<-rnorm(150)
y2<-rexp(150,3)
y3<-rpois(150,2)

squared_wass_approx(x,y1)
squared_wass_approx(x,y2)
squared_wass_approx(x,y3)

``````

goncalves-lab/waddR documentation built on June 29, 2023, 12:18 a.m.