Description Usage Arguments Value See Also Examples
We measure distance between two sets of empirical cumulative distribution functions (ECDF). For
simplicity, we only take an input of ecdf
objects from stats package.
1 |
elist1 |
a length M list of |
elist2 |
a length N list of |
type |
name of the distance/dissimilarity measure. Case insensitive. |
p |
exponent for |
an (M\times N) matrix of pairwise distances.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## toy example
# first list : 10 of random and uniform distributions
mylist1 = list()
for (i in 1:10){ mylist1[[i]] = stats::ecdf(stats::rnorm(50, sd=2))}
for (i in 11:20){mylist1[[i]] = stats::ecdf(stats::runif(50, min=-5))}
# second list : 15 uniform and random distributions
mylist2 = list()
for (i in 1:15){ mylist2[[i]] = stats::ecdf(stats::runif(50, min=-5))}
for (i in 16:30){mylist2[[i]] = stats::ecdf(stats::rnorm(50, sd=2))}
## compute Kolmogorov-Smirnov distance
dm2ks = pdist2(mylist1, mylist2, type="KS")
dm2lp = pdist2(mylist1, mylist2, type="lp")
dm2wa = pdist2(mylist1, mylist2, type="wasserstein")
nrs = nrow(dm2ks)
## visualize
opar = par(mfrow=c(1,3))
image(dm2ks[,nrs:1], axes=FALSE, main="Kolmogorov-Smirnov")
image(dm2lp[,nrs:1], axes=FALSE, main="L2")
image(dm2wa[,nrs:1], axes=FALSE, main="Wasserstein")
par(opar)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.