# Does Sage have a function that generates a random double stochastic matrix in which the elements of each row and each column add to one?

Each element is a random probability and no elements are negative.

edit retag close merge delete

Sort by ยป oldest newest most voted

There is a theorem that says that every doubly stochastic matrix is a linear combination of permutation matrices.

If you want random stochastic matrices, generate random linear combinations of permutations. See where that gets you.

It is called the Birkhoff Von Neumann theorem, by the way.

And there is this, too:

http://www.sagemath.org/doc/reference...

Nathann

more

not very efficient... if you want a n x n matrix then you will need to take care of the n! permutations.

( 2014-07-26 16:08:10 +0200 )edit
1

1) depends what you want to do with it, you may be happy with a sum of 5 matrices 2) can be implemented with 4 lines of Sage 3) better than having no way out at all 4) Advertises a cool result

( 2014-07-27 23:03:44 +0200 )edit