Re: Random Matrix of Integers

• To: mathgroup at smc.vnet.net
• Subject: [mg48612] Re: Random Matrix of Integers
• From: "Peter Pein" <petsie at arcor.de>
• Date: Mon, 7 Jun 2004 05:33:56 -0400 (EDT)
• References: <200406040851.EAA23928@smc.vnet.net> <c9scag\$bt6\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```"Oleksandr Pavlyk" <pavlyk at phys.psu.edu> schrieb im Newsbeitrag
news:c9scag\$bt6\$1 at smc.vnet.net...
> 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
>
>
Really?

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

--
Peter Pein, Berlin
to write to me, start the subject with [

```