I want to generate an $N\times N$ matrix $A$ so as to target an $N$ vector of row sums and simultaneously all column sums should sum to 1. In addition to this, I have a prefixed number of elements which are set to zero. For example, beginning with:$$  \left[\begin{array}{rrr}    0 & 1 & 1 \\    1 & 0 & 0 \\    1 & 1 & 0  \end{array}\right]$$and the row sum vector $[1.5, 0.25, 1]^{T}$, I want to end up with$$  \left[\begin{array}{rrr}    0 & a_{12} & a_{13} \\    a_{21} & 0 & 0 \\    a_{31} & a_{32} & 0  \end{array}\right]$$under the following conditions:$a_{12} + a_{13}  = 1.5$$ a_{21} = 0.25$$a_{31}+a_{32} = 1$$a_{21}+a_{31} = 1$$a_{12}+a_{32} = 1$$a_{13} = 1$While this is simplistic, in general, I have $2N$ equations in $N^{2}-Z$ unknowns, where $Z$ is the number of elements fixed to zero. So, this system of equations could be overdetermined or underdetermined, but I would like to be able to generate matrices like this such that all nonzero elements lie in $(0,1]$.
Computation of a column-stochastic matrix with target row sums
statistics;algorithms;graphs;social network analysis