[Date Index]
[Thread Index]
[Author Index]
RE: Re: Re: Random Matrix of Integers
*To*: mathgroup at smc.vnet.net
*Subject*: [mg48655] RE: [mg48615] Re: [mg48612] Re: Random Matrix of Integers
*From*: "Ellis, George" <George.Ellis at Cognos.COM>
*Date*: Wed, 9 Jun 2004 04:17:38 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
Dear Peter and Sasha,
I get Peter's result if I run the two code snippets code without first
loading the appropriate package from the Statistics Add-on; that is
RandonArray appears to complete the Do loop task in 0.04 second and
Table[Random[Interger.. Takes 0.451 second.
However, when I first load "<<Statistics`Master`" and then execute the
two snippets: RandomArray takes 2.133 second and Table[Random[Interger..
Takes, again, 0.451.
I apologize for the abbreviations above. However, it appears that Peter
has not loaded the DiscreteDistributions package before running the
code. (I think I know, because I did the same thing :-)
Regards,
George
-----Original Message-----
From: Oleksandr Pavlyk [mailto:pavlyk at phys.psu.edu]
To: mathgroup at smc.vnet.net
Subject: [mg48655] [mg48615] Re: [mg48612] Re: Random Matrix of Integers
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
>>
>>
This message may contain privileged and/or confidential information. If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so. Thank you.
Prev by Date:
**Re: Fwd: Re: what actually is in the WRI "functions" database?**
Next by Date:
**Re: What is zero divided by zero?**
Previous by thread:
**Re: Random Matrix of Integers**
Next by thread:
**Re: Re: Random Matrix of Integers**
| |