Re: Random Matrix of Integers

• To: mathgroup at smc.vnet.net
• Subject: [mg48557] Re: [mg48544] Random Matrix of Integers
• From: Oleksandr Pavlyk <pavlyk at phys.psu.edu>
• Date: Sat, 5 Jun 2004 07:18:57 -0400 (EDT)
• Organization: Penn State University; Department of Physics
• References: <200406040851.EAA23928@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Bruce,

Random is using uniform distribution, so
the it should be used with RandomArray.

In[1]:=
<< "Statistics`"
In[11]:=
RandomArray[
DiscreteUniformDistribution[8], {4, 4}] + 1
Out[11]=
{{4, 3, 4, 4}, {7, 2, 2, 6},
{5, 2, 7, 4}, {6, 8, 2, 9}}

However note that RandomArray is much slower

In[2]:=
Timing[Do[RandomArray[
DiscreteUniformDistribution[8], {4, 4}] + 1,
{k, 1, 10000}]]
Out[2]=
{3.636*Second, Null}
In[3]:=
Timing[Do[Table[Random[
Integer, {2, 9}], {4},
{4}], {k, 1, 10000}]]
Out[3]= {0.6609999999999996*Second, Null}

Sasha

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.
>
> Bruce

```

• Prev by Date: RE: PlotPoints in plot
• Next by Date: Re: PlotPoints in plot
• Previous by thread: Re: Random Matrix of Integers
• Next by thread: Re: Random Matrix of Integers