  We develop improved rearrangement algorithms to find the dependence structure
that minimizes a convex function of the sum of dependent variables with given
margins. We propose a new multivariate dependence measure, which can assess the
convergence of the rearrangement algorithms and can be used as a stopping rule.
We show how to apply these algorithms for example to finding the dependence
among variables for which the marginal distributions and the distribution of
the sum or the difference are known. As an example, we can find the dependence
between two uniformly distributed variables that makes the distribution of the
sum of two uniform variables indistinguishable from a normal distribution.
Using MCMC techniques, we design an algorithm that converges to the global
optimum.
