restart;
A:=LinearAlgebra:-RandomMatrix(3,4,generator=0..1.0 );
for n from 1 to LinearAlgebra:-RowDimension(A) do
A[n,..]:=A[n,..]/add(A[n,..]);
od:
A;
#verify each row sums to 1
map(x->add(x),[LinearAlgebra:-Row(A,[1..-1])])
|
[0.9705927818 0.9575068354 0.0975404050 0.1269868163]
[ ]
A := [0.1576130817 0.5468815192 0.6323592462 0.9057919371]
[ ]
[0.9648885352 0.2784982189 0.9133758561 0.8147236864]
[0.4508876154 0.4448085560 0.0453122684 0.0589915605]
[ ]
[0.0702799715 0.2438555046 0.2819701848 0.4038943392]
[ ]
[0.3247157951 0.0937235414 0.3073801341 0.2741805296]
[1.00000000026568, 1.00000000004739, 1.00000000023679]
|