Previous Up Next

2.41.3Random matrix : ranm randMat randmatrix

ranm or randMat or randmatrix takes as argument an integer n or two integers n,m and optionnally a third argument, either an integer k or the quoted name of a random distribution law (see also 2.24.25, 2.37.36 and ??).
ranm returns a vector of size n or a matrix of size n m containing random integers uniformally distributed between -99 and +99 (default), or between 0 and k−1 or a matrix of size n m containing random integers according to the law put between quotes.
Input :

ranm(3)

Output :

[-54,78,-29]

Input :

ranm(2,4)

Output :

[[27,-29,37,-66],[-11,76,65,-33]]

Input :

ranm(2,4,3)

Or input :

ranm(2,4,’rand(3)’)

Output :

[[0,1,1,0],[0,1,2,0]]

Input :

ranm(2,4,’randnorm(0,1)’)

Output :

[[1.83785427742,0.793007112053,-0.978388964902,-1.88602023857], [-1.50900874199,-0.241173369698,0.311373795585,-0.532752431454]]

Input :

ranm(2,4,2..4)

Output :

[[2.00549363438,3.03381264955,2.06539073586,2.04844321217], [3.88383254968,3.28664474655,3.76909781061,2.39113253355]]

Previous Up Next