TITLE: How do I Generate Doubly-Stochastic Matrices Uniform Randomly?
QUESTION [13 upvotes]: A doubly-stochastic matrix is an $n\times n$ matrix $P$ such that
$\displaystyle\sum_{i=1}^n{p_{ij}}=1$
and
$\displaystyle\sum_{j=1}^n{p_{ij}}=1$
where $p_{ij}\ge 0$.
Can someone suggest an algorithm for generating these matrices uniform randomly?

REPLY [3 votes]: You can first generate a random unitary matrix and then square the absolute values of all entries. Here is Mathematica code that does this:
(* Random real and complex numbers with normal distribution *)
RR := RandomReal[NormalDistribution[0, 1]];
RC := RR + I*RR;
(* Random matrix from Ginibre ensemble *)
RG[n_] := Table[RC, {n}, {n}];
(* Random unitary matrix *)
RU[n_] := Orthogonalize[RG[n]];
(* Random doubly stochastic matrix *)
RDS[n_] := Abs[RU[n]]^2;

Run RDS[5] to generate a $5 \times 5$ random doubly stochastic matrix.