View source: R/special_spd_wassbary.R
spd.wassbary | R Documentation |
Given N observations X_1, X_2, …, X_N in SPD manifold, compute the L_2-Wasserstein barycenter that minimizes
∑_{n=1}^N λ_i \mathcal{W}_2 (N(X), N(X_i))^2
where N(X) denotes the zero-mean Gaussian measure with covariance X.
spd.wassbary(spdobj, weight = NULL, method = c("RU02", "AE16"), ...)
spdobj |
a S3 |
weight |
weight of observations; if |
method |
name of the algortihm to be used; one of the |
... |
extra parameters including
|
a (p\times p) Wasserstein barycenter matrix.
#------------------------------------------------------------------- # Covariances from standard multivariate Gaussians. #------------------------------------------------------------------- ## GENERATE DATA ndata = 20 pdim = 10 mydat = array(0,c(pdim,pdim,ndata)) for (i in 1:ndata){ mydat[,,i] = stats::cov(matrix(rnorm(100*pdim), ncol=pdim)) } myriem = wrap.spd(mydat) ## COMPUTE BY DIFFERENT ALGORITHMS baryRU <- spd.wassbary(myriem, method="RU02") baryAE <- spd.wassbary(myriem, method="AE16") ## VISUALIZE opar <- par(no.readonly=TRUE) par(mfrow=c(1,3), pty="s") image(diag(pdim), axes=FALSE, main="True Covariance") image(baryRU, axes=FALSE, main="by RU02") image(baryAE, axes=FALSE, main="by AE16") par(opar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.