[Date Index]
[Thread Index]
[Author Index]
Re: Re: Random Matrix of Integers
*To*: mathgroup at smc.vnet.net
*Subject*: [mg48615] Re: [mg48612] Re: Random Matrix of Integers
*From*: Oleksandr Pavlyk <pavlyk at phys.psu.edu>
*Date*: Tue, 8 Jun 2004 00:48:06 -0400 (EDT)
*Organization*: Penn State University; Department of Physics
*References*: <200406040851.EAA23928@smc.vnet.net> <c9scag$bt6$1@smc.vnet.net> <200406070933.FAA11076@smc.vnet.net>
*Reply-to*: pavlyk at phys.psu.edu
*Sender*: owner-wri-mathgroup at wolfram.com
Peter Pein wrote:
>
> 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}
Dear Peter,
I can not confirm your timings ratio.
On my PC and with my copy of Mathematica 5.0.1
Table[Random[Integer,{2,9}],{4},{4}]
consistently outperforms RandomArray.
In[37]:=
Quit
In[8]:=
$Version
Out[8]=
"5.0 for Microsoft Windows (November 18, 2003)"
In[1]:=
<< "Statistics`"
In[2]:=
Timing[Do[RandomArray[
DiscreteUniformDistribution[8], {4, 4}] + 1,
{k, 1, 10000}]]
Out[2]=
{2.924*Second, Null}
In[3]:=
Timing[Do[Table[Random[
Integer, {2, 9}], {4},
{4}], {k, 1, 10000}]]
Out[3]=
{0.601*Second, Null}
It occurred to me that we might be using different Mathematica
versions, so I ran this code on Solaris Mathematica 4.1
Mathematica 4.1 for Sun Solaris
Copyright 1988-2000 Wolfram Research, Inc.
-- Terminal graphics initialized --
In[1]:= <<Statistics`
In[2]:= Timing[Do[RandomArray[
DiscreteUniformDistribution[8], {4, 4}] + 1,
{k, 1, 10000}]]
Out[2]= {11.23 Second, Null}
In[3]:= Timing[Do[Table[Random[
Integer, {2, 9}], {4},
{4}], {k, 1, 10000}]]
Out[3]= {4.88 Second, Null}
with essentially the same outcome: Random[Integer,{2,9}]
is faster. It makes perfect sense to me that StandardPackage
function is slower than the built in one, otherwise it would
be wise to make the former built-in.
Are your results consistent ? I mean can you reproduce them
in the freshly started kernel ? what is your cpu and mathematica
version ?
Regards,
Sasha
> "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
>>
>>
Prev by Date:
**Re: Re: Re: Re: What is zero divided by zero?**
Next by Date:
**Re: Re: Re: Re: What is zero divided by zero?**
Previous by thread:
**Re: Random Matrix of Integers**
Next by thread:
**Re: Random Matrix of Integers**
| |