Skip to contents

Given a collection of Gaussian distributions \(\mathcal{N}(\mu_i, \sigma_i^2)\) for \(i=1,\ldots,n\), compute the Wasserstein-2 barycenter exactly: average the means and standard deviations separately, then square the resulting standard deviation. The iteration controls are retained and validated for compatibility.

Usage

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

Arguments

means

a length-\(n\) vector of mean parameters.

vars

a length-\(n\) vector of finite nonnegative variances. Zero denotes a degenerate Gaussian point mass.

weights

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

...

extra parameters including

abstol

absolute numerical tolerance (default: 1e-8).

reltol

relative numerical tolerance (default: 1e-8).

maxiter

maximum number of iterations (default: 496).

Value

A named list preserving the mean and variance fields below, with objective, accepted history, status, stopping reason, iteration count, and numerical diagnostics. Non-success produces a warning.

mean

mean of the estimated barycenter distribution.

var

variance of the estimated barycenter distribution.

References

There are no references for Rd macro \insertAllCites on this help page.

See also

[T4transport::gaussbarypd()] for multivariate case.

Examples

#----------------------------------------------------------------------
#                         Two Gaussians
#
# Two Gaussian distributions are parametrized as follows.
# Type 1 : (mean, var) = (-4, 1/4)
# Type 2 : (mean, var) = (+4, 1/4)
#----------------------------------------------------------------------
# GENERATE PARAMETERS
par_mean = c(-4, 4)
par_vars = c(0.25, 0.25)

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

# QUANTITIES FOR PLOTTING
x_grid  = seq(from=-6, to=6, length.out=200)
y_dist1 = stats::dnorm(x_grid, mean=-4, sd=0.5)
y_dist2 = stats::dnorm(x_grid, mean=+4, sd=0.5)
y_gmean = stats::dnorm(x_grid, mean=gmean$mean, sd=sqrt(gmean$var)) 

# VISUALIZE
opar <- par(no.readonly=TRUE)
plot(x_grid, y_gmean, lwd=2, col="red", type="l",
     main="Barycenter", xlab="x", ylab="density")
lines(x_grid, y_dist1)
lines(x_grid, y_dist2)

par(opar)