# histbary15B: Barycenter of Histograms by Benamou et al. (2015) In T4transport: Tools for Computational Optimal Transport

 histbary15B R Documentation

## Barycenter of Histograms by Benamou et al. (2015)

### Description

Given multiple histograms represented as "histogram" S3 objects, compute Wasserstein barycenter. We need one requirement that all histograms in an input list hists must have same breaks. See the example on how to construct a histogram on predefined breaks/bins.

### Usage

histbary15B(hists, p = 2, weights = NULL, lambda = NULL, ...)


### Arguments

 hists a length-N list of histograms ("histogram" object) of same breaks. p an exponent for the order of the distance (default: 2). weights a weight of each image; if NULL (default), uniform weight is set. Otherwise, it should be a length-N vector of nonnegative weights. lambda a regularization parameter; if NULL (default), a paper's suggestion would be taken, or it should be a nonnegative real number. ... extra parameters including abstolstopping criterion for iterations (default: 1e-8). init.vecan initial weight vector (default: uniform weight). maxitermaximum number of iterations (default: 496). nthreadnumber of threads for OpenMP run (default: 1). print.progressa logical to show current iteration (default: TRUE).

### Value

a "histogram" object of barycenter.

### References

\insertRef

benamou_iterative_2015T4transport

bary15B

### Examples

#----------------------------------------------------------------------
#                      Binned from Two Gaussians
#
# EXAMPLE : Very Small Example for CRAN; just showing how to use it!
#----------------------------------------------------------------------
# GENERATE FROM TWO GAUSSIANS WITH DIFFERENT MEANS
set.seed(100)
x  = stats::rnorm(1000, mean=-4, sd=0.5)
y  = stats::rnorm(1000, mean=+4, sd=0.5)
bk = seq(from=-10, to=10, length.out=20)

# HISTOGRAMS WITH COMMON BREAKS
histxy = list()
histxy[[1]] = hist(x, breaks=bk, plot=FALSE)
histxy[[2]] = hist(y, breaks=bk, plot=FALSE)

# COMPUTE
hh = histbary15B(histxy, maxiter=5)

# VISUALIZE
par(mfrow=c(1,2))
barplot(histxy[[1]]$density, col=rgb(0,0,1,1/4), ylim=c(0, 0.75), main="Two Histograms") barplot(histxy[[2]]$density, col=rgb(1,0,0,1/4),
barplot(hh\$density, main="Barycenter",
ylim=c(0, 0.75))
par(opar)



T4transport documentation built on April 12, 2023, 12:37 p.m.