Suppose we are given a probability distribution over a finite discrete product space $p(x,y)$ with marginals $p(x), p(y) > 0$ for each $x,y$ respectively. We are given two more marginal distributions $r(x), r(y)>0,$ for each $x,y$ respectively. Can we always find functions $f(x), g(y)$ such that
$\sum_y p(x,y)f(x)g(y) = r(x)$
$\sum_x p(x,y)f(x)g(y) = r(y)$?
It appears that we should always be able to do this, but I would like an explicit expression for a solution $f,g$ in terms of $r(x), r(y).$ Thanks.