Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

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>
  • Reply-to: pavlyk at phys.psu.edu
  • 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