MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Random Matrix of Integers


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


  • Prev by Date: Re: Random Matrix of Integers
  • Next by Date: Re: Advection-Diffusion Equation with variable coefficients
  • Previous by thread: RE: Random Matrix of Integers
  • Next by thread: Re: Random Matrix of Integers