I'm trying to determine an analytic formula for the Wasserstein-1 distance between two Laplace distributions.
Since the distriutions are in 1D, I can use the relationship between the W1 distance and the $L_1$ difference of the cumulative density functions:
$$ \mathbb{W}(\mathrm{L}(\mu_1,b_1),\mathrm{L}(\mu_2,b_2)) = \int_{x\in\mathbb{R}} |c_1(x)-c_2(x)| $$
where $c_i(x) = \frac{1}{2}e^{\frac{x-\mu_i}{b_i}}$ when $x \leq \mu_i$ and $1-\frac{1}{2}e^{-\frac{x-\mu_i}{b_i}}$ otherwise (sorry I can't write this as a piecewise function; the SE editor thinks it's code and won't let me publish the question).
We can tell already that this is a simple integral in the sense that it breaks down into sums of exponential integrals. I was hoping Mathematica could spare me from filling in the details, so I wrote the following code:
f1[x_] := Piecewise[{{0.5*Exp[(x - \[Mu]1)/b1], x < \[Mu]1}, {1 - 0.5*Exp[-(x - \[Mu]1)/b1], x > \[Mu]1}}]
f2[x_] := Piecewise[{{0.5*Exp[(x - \[Mu]2)/b2], x < \[Mu]2}, {1 - 0.5*Exp[-(x - \[Mu]2)/b2], x > \[Mu]2}}]
Integrate[Abs[f1[x] - f2[x]], {x, -Infinity, Infinity}, Assumptions -> {b1 > 0, b2 > 0,Element[\[Mu]1, Reals], Element[\[Mu]2, Reals]}]
Unfortunately, this code doesn't work (it just returns the integral statement).
Is there a better way to formulate this integral?
1/2
, not0.5
, as1/2
is an exact number and0.5
is a machine number (subject to machine arithmetic and rounding errors). Unfortunately, this change doesn't help mathematica integrate the expression. $\endgroup$Integrate[ Piecewise[{{(1/2)*Exp[(x - 3)], x < 3}, {1 - (1/2)*Exp[-(x - 3)], x > 3}}], x]
looks like a reasonable answer as it is continuous at x=3 butIntegrate[ Piecewise[{{(1/2)*Exp[(x - \[Mu]1)], x < \[Mu]1}, {1 - (1/2)*Exp[-(x - \[Mu]1)], x > \[Mu]1}}], x]
is not continuous at x= [Mu]1 $\endgroup$