Gretton et al. (2007) introduced Maximum Mean Discrepancy (MMD). EasyMMD in an R package which provides a simple (hopefully!) and computationally efficient way to compute the MMD between two datasets.
You can install EasyMMD from github with:
devtools::install_github("AnthonyEbert/EasyMMD")
This is a basic example which shows you how to solve a common problem:
library(EasyMMD) n <- 1e3 x <- rnorm(n) y <- rnorm(n, 5) MMD(y,x) # For faster computation, precompute part of the MMD for the observed data y y_kmmd <- kmmd(y) MMD(y,x, y_kmmd) microbenchmark::microbenchmark(MMD(y,x), MMD(y,x, y_kmmd), times = 10)
Gretton, A., Borgwardt, K. M., Rasch, M., Schölkopf, B., & Smola, A. J. (2007). A kernel method for the two-sample-problem. In Advances in neural information processing systems (pp. 513-520).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.