Dear GAP-Forum, and Stas,
as an alternative to Sven's solution (which will almost surely come up
with a matrix of a prescribed weight; I don't know if that's what you
want?), you could `flip an unfair coin' for every entry:
r:=[1..10]; p:=2; coin:=function() if Random(r)>p then return 0*Z(2); else return Z(2); fi; end; n1:=5; n2:=5; A:=List([1..n1],i->List([1..n2],j->coin()));
This gives a matrix in which on average 20% of the entries are ones.
This is probably less efficient than Sven's solution, but the underlying
probability model is easier. So it depends on your application which
solution to use.