Re: Random Matrix of Integers

*To*: mathgroup at smc.vnet.net*Subject*: [mg48555] Re: Random Matrix of Integers*From*: "Curt Fischer" <crf3 at po.cwru.edu>*Date*: Sat, 5 Jun 2004 07:18:55 -0400 (EDT)*References*: <c9pfmg$suf$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Bruce W. Colletti wrote: > To create a 4x4 matrix of random integers drawn from {2..9}, I use: > > A = Table[Random[Integer, {2, 9}], {4}, {4}] > How can I do this using RandomArray? Thanks. In[1]:= <<Statistics`DiscreteDistributions` In[2]:= mat=Map[Plus[#,1]&,RandomArray[DiscreteUniformDistribution[8],{4,4}],{2}]; mat//MatrixForm DiscreteUniformDistribution gets you an array whose elements are uniformly distributed on {1...8}. If we add one to each element of this matrix we get the domain you want. -- Curt Fischer