Statistics & probability

One dimensional Wasserstein barycenter calculator for discrete distributions

Find the weighted one-dimensional W2 barycenter of finite discrete probability measures by averaging their quantile functions.

Your numbers

One support row per point; distribution indices start at 0 and each measure has positive masses summing to 1.
2–8 positive weights summing to 1, in distribution-index order.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Find the weighted one-dimensional W2 barycenter of finite discrete probability measures by averaging their quantile functions.

THE FORMULAQ_bar(t)=Σw_i Q_i(t); objective=∫₀¹Σw_i[Q_i(t)−Q_bar(t)]²dt.

A worked example

Weights 0.25 and 0.75 combine default measures {0,2} and {2,6}, each with equal atom masses, into atoms 1.5 and 5 with mass 0.5 each. The minimized objective is 1.875.

Good to know

2–8 one-dimensional measures, each with 1–40 support masses at least 1e−9 summing to 1, and barycentric weights at least 1e−9 summing to 1. Merged quantile-interval integration in floating decimal arithmetic with normalization tolerance. No entropic smoothing, multidimensional extension or W1 median interpretation.

A barycenter is a new probability measure

Transport distance compares two fixed distributions, whereas a barycenter finds a new distribution that summarizes several inputs. Here the objective is a weighted sum of squared one-dimensional W2 distances. The unknown is the entire consensus measure, including the locations and masses of its atoms, rather than one chosen point or one coupling table.

This distinction matters when source distributions have different support locations. Averaging their probabilities at a fixed grid would mix their mass without necessarily moving it to intermediate positions. A Wasserstein barycenter instead averages quantile locations, reflecting the geometry of the real line and the squared-distance transport cost.

One dimensional Wasserstein barycenter calculator for discrete distributions worked exampleInput 0: 0, 2Input 1: 2, 6Barycenter: 1.5, 5 · mass 0.5 each
Scroll across to see the full diagram.
Weights 0.25 and 0.75 combine default measures {0,2} and {2,6}, each with equal atom masses, into atoms 1.5 and 5 with mass 0.5 each. The minimized objective is 1.875.

Compare this with the Entropy regularized optimal transport calculator from a cost matrix. Find a weighted consensus distribution minimizing the sum of squared W2 distances to several input measures; pairwise entropic transport returns a coupling between two fixed marginals, not a new barycenter.

Enter measures and their separate weights

Each support row contains a zero-based distribution index, a numeric support position and its probability mass. Every entered distribution must have positive masses that sum to one within the stated tolerance. Support rows can be unsorted because the calculator orders them before constructing cumulative probabilities.

The separate barycentric weights describe the relative importance of whole distributions, not the probability masses inside each distribution. They also sum to one and must be positive. Confusing these two kinds of weights can produce a valid numerical result for a completely different question, so the interface keeps them in separate fields.

Quantile intervals make the calculation finite

In one dimension, squared W2 distance equals the integral of the squared difference between quantile functions. A finite discrete measure has a stepwise constant quantile function. Collecting every cumulative-mass breakpoint from every measure therefore partitions the unit probability interval into finitely many regions where all input quantiles are constant.

On each region, the weighted mean of those quantile values minimizes the weighted squared deviation. Its interval width becomes an atom mass in the barycenter. Adjacent regions with exactly equal computed locations can combine into one atom, while the full interval table remains available to show how each consensus location was formed.

Read the weighted spread objective

The minimized objective is the integral of the weighted spread of the input quantile values around their weighted average. It has squared support units: if positions are measured in meters, the objective is in square meters. It is not itself the distance between any one input and the consensus.

A pairwise variance identity recomputes the same objective from weighted squared differences between input quantiles. Agreement checks the arithmetic independently of the chosen atom display. The result does not provide a sampling confidence interval or a hypothesis test; the distributions and barycentric weights are treated as supplied mathematical inputs.

Follow the two-measure worked example

The first default measure places equal masses at zero and two; the second places equal masses at two and six. Their quantile breakpoints coincide at one half. With barycentric weights one quarter and three quarters, the first consensus quantile is 1.5 and the second is five.

Each consensus atom receives mass one half. The weighted squared deviations are 0.75 on the first probability interval and three on the second, giving total objective one half times 0.75 plus one half times three, or 1.875. This calculation shows why the consensus positions differ from a simple pooled mixture’s four support locations.

Normalization and numerical conventions

Decimal masses are evaluated with floating arithmetic and checked against a strict normalization tolerance. The mathematical quantile construction is finite and exact in form, but the displayed decimal endpoints and costs should not be interpreted as symbolic rational certificates. Tiny input rounding differences can create or merge nearby probability breakpoints.

The calculator does not clip negative masses or silently invent a missing final probability. Every mass must be positive, and every indexed distribution must be present. Repeated support positions are permitted because they can represent separate rows of mass at the same location; their quantile contributions agree and can combine in the returned measure.

When another transport problem is needed

The result is specific to one-dimensional W2 barycenters. A W1 barycenter uses median-type quantile behavior rather than the weighted mean used here, and a multidimensional barycenter does not generally have the same direct quantile solution. Entropic regularization adds another modeling choice and is not silently inserted into this objective.

Several checks are especially useful: identical input measures must reproduce themselves, translating all support positions must translate the barycenter, and the barycenter’s mean must equal the weighted input means. Scaling positions scales the objective by the square of that factor. These identities verify the geometry without extending the supported probability model.

A few questions, answered

Why not just average the input probability masses?

A pooled mixture and a Wasserstein barycenter are different summaries. W2 averaging moves matched quantile locations and may create new support points.

What do the distribution weights mean?

They weight entire input measures in the squared-distance objective; they are separate from the atom masses within each measure.

Is the objective a distance?

It is a weighted sum of squared W2 distances, with squared support units, not a single unsquared transport distance.

Does the same formula work in two dimensions?

No. The direct weighted quantile formula relies on the order structure of the real line.

Find your calculator

Start typing to explore the library.