Suppose I want to generate a nonnegative $n \times n$ matrix $\mathbf A$ for an odd $n$ (say, $n=5$ for a good enough example), such that
- the individual elements are drawn from a uniform distribution
but with the equality constraints
the sum of all the elements in the rows above the mid row = the sum of all the elements in the rows below the mid row
the sum of all the elements in the columns left of the middle column = the sum of all the elements in the columns right of the middle column
the sum of all elements = 1.0
That is, in effect I want to generate matrices "balanced" in a specific way (I intend to use them as convolution matrices and I don't care about translation).
For my current purposes I think I have a good enough ad hoc (not entirely correctly distributed) solution that generates a uniform matrix and then enforces the equality constraints by correcting the individual elements using a least squares approach.
However I'm curious, mainly for the learning experience, if there would be some easy-ish way to sample the resulting conditional distribution. So far I've had a quick peek on Wikipedia into the Bates distribution (mean of uniform random variables) and into Monte Carlo Markov Chain models, but I'm not sure if they help here or if there would be an easier solution.
I'm not necessarily looking for a complete solution; pointers to insightful or helpful material are also appreciated.
Edit: I'm looking for the conditional probability distribution, i.e. the elements do not need to be uniformly distributed; rather, I'm looking for a distribution where each sample that satisfies the equality constraints has the same probability (hence conditional uniform distribution given the equalities).