WLpdist | R Documentation |
Given a collection of von Misees-Fisher (vMF) distributions, compute the pairwise distance using the Wasserstein-like distance from an approximate Wasserstein geometry.
WLpdist(means, concentrations)
means |
An |
concentrations |
A length- |
An (n \times n)
matrix of pairwise distances.
# Set seed for reproducibility
set.seed(123)
# Generate two classes of mean directions around north and south poles
means1 = array(0,c(50,2)); means1[,2] = rnorm(50, mean=1, sd=0.25)
means2 = array(0,c(50,2)); means2[,2] = rnorm(50, mean=-1, sd=0.25)
means1 = means1/sqrt(rowSums(means1^2))
means2 = means2/sqrt(rowSums(means2^2))
# Concatenate the mean directions
data_means = rbind(means1, means2)
# Generate concentration parameters
data_concentrations = rnorm(100, mean=20, sd=1)
# Compute the pairwise distance matrix
pdmat = WLpdist(data_means, data_concentrations)
# Visualise the pairwise distance matrix
opar <- par(no.readonly=TRUE)
image(pdmat, main="Pairwise Wasserstein-like Distance")
par(opar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.