Re: Re: simple question about random
- To: mathgroup at smc.vnet.net
- Subject: [mg58992] Re: [mg58960] Re: simple question about random
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Tue, 26 Jul 2005 04:02:06 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <dbv954$eah$1@smc.vnet.net> <200507250512.BAA04836@smc.vnet.net>
- Reply-to: murray at math.umass.edu
- Sender: owner-wri-mathgroup at wolfram.com
For 6 random numbers, not much difference. But for many, "inefficient"
hardly does justice to the dramatic performance difference:
Timing[Table[Random[], {100000}];]
{0.016 Second, Null}
Timing[rand = {};
Do[rand = Prepend[rand, Random[]], {100000}];]
{69.984 Second, Null}
ggroup at sarj.ca wrote:
> Hi David,
>
> Why wouldn't a Do/For loop work? The following seem to work just fine,
> even if they are somewhat bulky and inefficient.
>
> rand={};
> Do[rand=Prepend[rand,Random[]],{6}];
>
> rand1={};
> For[i=1,i=6,i++,rand1=Prepend[rand1,Random[]]];
>
> I personally would use Table or RandomArray, but...
>
>
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
- References:
- Re: simple question about random
- From: ggroup@sarj.ca
- Re: simple question about random