-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
71 lines (55 loc) · 2.35 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
output: github_document
bibliography: ./vignettes/testOTM.bib
nocite: '@*'
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.width = 8,
fig.height = 4.5,
dpi = 240
)
set.seed(2019)
```
# testOTM
<!-- badges: start -->
<!-- badges: end -->
`testOTM` is an R package that computes multivariate ranks and quantiles defined through the theory of optimal transportation. It also provides several applications of these statistics, most notably a method for two-sample multivariate goodness-of-fit testing.
## Installation
You can install the released version of `testOTM` from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("testOTM")
```
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
# devtools::install_github("Francis-Hsu/testOTM")
```
## Example
This is a basic example which shows you how to use `testOTM` to visualize the optimal transport map from $U[0, 1]^2$ to a (scaled) bivariate Gaussian sample:
```{r example}
library(testOTM)
# generate bivariate normal data
p = 2
n = 100
Sigma = matrix(c(2, 1, 1, 2), 2, 2)
eS = eigen(Sigma, symmetric = TRUE)
X = t(eS$vectors %*% diag(sqrt(pmax(eS$values, 0)), p) %*% matrix(rnorm(p * n), p))
# compute the optimal transport map from U[0, 1]^2 to the data
# notice that the data will be scale into [0, 1] range
X.OTM = tos.fit(X)
# plot the restricted Voronoi diagram and the restricted Delaunay triangulation
oldpar = par(mfrow = c(1, 2))
plot(X.OTM, which = "Both", draw.center = F, draw.map = T)
par(oldpar)
```
```{r unseed, include = FALSE}
rm(.Random.seed, envir = globalenv())
```
## Acknowledgment
The author is extremely grateful to Prof. [Bodhisattva Sen](http://www.stat.columbia.edu/~bodhi/Bodhi/Welcome.html) and his student Promit Ghosal for their guidance in the development of this package. The author would also like to thank Dr. [Bruno Lévy](https://members.loria.fr/BLevy/) for his assistance with the [Geogram](http://alice.loria.fr/index.php/software/4-library/75-geogram.html) library, and the [TraME](http://www.trame-project.com/) team, whose [`Rgeogram`](https://github.com/TraME-Project/Rgeogram) package provides inspirations to the early build of this package.
## Reference