# MMD: Compute the MMD between two samples In AnthonyEbert/EasyMMD: Allows users to compute the Maximum Mean Discrepancy (MMD) between two samples

## Description

This function returns the estimator for the two-sample MMD.

## Usage

 ```1 2``` ```MMD(y, x, y_kmmd = NULL, var = 1, bias = FALSE, threshold = Inf, approx_exp = 0, sigma = NULL) ```

## Arguments

 `y` either a numeric vector or matrix with number of rows equal to number of observations and number of columns equal to dimension of observations. `x` either a numeric vector or matrix with number of rows equal to number of observations and number of columns equal to dimension of observations. `y_kmmd` precomputed first term in MMD calculation. `var` matrix kernel variance covariance matrix. `bias` logical; if `TRUE` the biased MMD is computed rather than the unbiased MMD. This can be useful since the biased MMD is always positive. `threshold` numeric filter out values for exponentiation. `approx_exp` integer; if 0 the usual function for the exponential distribution is used; if 1 a much faster but less accurate version of the exponential distribution is used. `sigma` numeric DEPRECATED square root of variance.

## References

Gretton, Arthur, et al. "A kernel method for the two-sample-problem." Advances in neural information processing systems. 2007.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``` ```set.seed(1) y <- rnorm(2000) x <- rnorm(2000, 5) MMD_1 <- MMD(y, x) MMD_1 # Precompute y_kmmd for faster speed y_kmmd <- kmmd(y) MMD_2 <- MMD(y, x, y_kmmd) MMD_2 system.time(MMD_1 <- MMD(y, x)) system.time(MMD_2 <- MMD(y, x, y_kmmd)) # Different var MMD_4 <- MMD(y, x, var = 0.25) ```

AnthonyEbert/EasyMMD documentation built on May 29, 2018, 8:05 a.m.