wasserstein_permut: Permutation test based on Wasserstein distance

View source: R/wassertsein_permut.R

wasserstein_permutR Documentation

Permutation test based on Wasserstein distance

Description

Permutation test based on Wasserstein distance

Usage

wasserstein_permut(
  x,
  y,
  iterations = 10^4,
  fast = nrow(x) + nrow(y) > 10^3,
  S = NULL,
  ...
)

Arguments

x

Samples from the first distribution

y

Samples from the second distribution. Only used if x is a vector.

iterations

How many iterations to do to simulate the null distribution. Default to 10^4.

fast

If true, uses the subwasserstein approximate function. Default to true if there are more than 1,000 samples total.

S

Number of samples to use in approximate mode. Must be set if fast=TRUE. See subwasserstein.

...

Other parameters passed to wasserstein or wasserstein1d

Value

A list containing the following components:

  • statistic the Wasserstein distance between x and y.

  • p.value the p-value of the permutation test.

Examples

 x <- matrix(c(runif(100, 0, 1),
               runif(100, -1, 1)),
             ncol = 2)
 y <- matrix(c(runif(100, 0, 3),
               runif(100, -1, 1)),
             ncol = 2)
 # Set iterations to small number for runtime
 # Increase for more accurate results
 wasserstein_permut(x, y, iterations = 10^2)

HectorRDB/Ecume documentation built on June 4, 2024, 11:52 a.m.