The title says it all.
Given two measurable functions $f:X\to \mathbb C$ and $g:Y\to \mathbb C$, where $(X,\mu)$ and $(Y,\nu)$ are two probability spaces, suppose they have the same distributions.
Is it true that there exists a measure-preserving measurable function $\phi:X\to Y$
$\nu(\phi(U)) = \mu(U)$ and $\mu(\phi^{-1}(V)) = \nu(V)$
such that $f = g \circ \phi$ almost everywhere?