Learn R Programming

T4transport (version 0.1.2)

gaussbarypd: Barycenter of Gaussian Distributions in \(\mathbf{R}^p\)

Description

Given a collection of \(n\)-dimensional Gaussian distributions \(\mathcal{N}(\mu_i, \Sigma_i^2)\) for \(i=1,\ldots,n\), compute the Wasserstein barycenter of order 2. For the barycenter computation of variance components, we use a fixed-point algorithm by AlvarezEsteban;textualT4transport.

Usage

gaussbarypd(means, vars, weights = NULL, ...)

Value

a named list containing

mean

a length-\(p\) vector for mean of the estimated barycenter distribution.

var

a \((p\times p)\) matrix for variance of the estimated barycenter distribution.

Arguments

means

an \((n\times p)\) matrix whose rows are mean vectors.

vars

a \((p\times p\times n)\) array where each slice is covariance matrix.

weights

a weight of each image; if NULL (default), uniform weight is set. Otherwise, it should be a length-\(n\) vector of nonnegative weights.

...

extra parameters including

abstol

stopping criterion for iterations (default: 1e-8).

maxiter

maximum number of iterations (default: 496).

References

See Also

gaussbary1d() for univariate case.

Examples

Run this code
# \donttest{
#----------------------------------------------------------------------
#                         Two Gaussians in R^2
#----------------------------------------------------------------------
# GENERATE PARAMETERS
# means
par_mean = rbind(c(-4,0), c(4,0))

# covariances
par_vars = array(0,c(2,2,2))
par_vars[,,1] = cbind(c(4,-2),c(-2,4))
par_vars[,,2] = cbind(c(4,+2),c(+2,4))

# COMPUTE THE BARYCENTER OF EQUAL WEIGHTS
gmean = gaussbarypd(par_mean, par_vars)

# GET COORDINATES FOR DRAWING
pt_type1 = gaussvis2d(par_mean[1,], par_vars[,,1])
pt_type2 = gaussvis2d(par_mean[2,], par_vars[,,2])
pt_gmean = gaussvis2d(gmean$mean, gmean$var)

# VISUALIZE
opar <- par(no.readonly=TRUE)
plot(pt_gmean, lwd=2, col="red", type="l",
     main="Barycenter", xlab="", ylab="", 
     xlim=c(-6,6))
lines(pt_type1)
lines(pt_type2)
par(opar)
# }

Run the code above in your browser using DataLab