Generate the random matrix and divide each column by its total
A:=LinearAlgebra:-RandomMatrix(3,4);
[ 9 -95 51 24] [ ] A := [99 -20 76 65] [ ] [60 -25 -44 86]
b:=MTM:-sum(A,1); #sum columns b := [168, -140, 83, 175]
nCol:=LinearAlgebra:-ColumnDimension(A): B:=convert([seq(A[..,i]/b[i],i=1..nCol)],Matrix);
[3 19 51 24 ] [-- -- -- ---] [56 28 83 175] [ ] [33 1 76 13] B := [-- - -- --] [56 7 83 35] [ ] [5 5 -44 86 ] [-- -- --- ---] [14 28 83 175]
MTM:-sum(B,1);
[1, 1, 1, 1]