s-news
[Top] [All Lists]

Re: scalability

To: David L Lorenz <lorenz@usgs.gov>
Subject: Re: scalability
From: Patrick Burns <pburns@pburns.seanet.com>
Date: Fri, 26 Mar 2004 21:08:06 +0000
Cc: s-news@lists.biostat.wustl.edu
References: <OF08949065.1D44A7AE-ON86256E63.006E1A84@cr.usgs.gov>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.0.1) Gecko/20020823 Netscape/7.0
I just tried your problem in R (Windows version 1.8.1):

> set.seed(2)
> jja <- array(rnorm(3000*300*3), c(3000,300,3))
> system.time(jjsa <- apply(jja, 1:2, sum))
[1] 75.21  0.45 99.43    NA    NA
> dim(jjsa)
[1] 3000  300

So the solution  arrives in 100 seconds on a P3 744 MHz laptop
with 256M of memory.

Patrick Burns

Burns Statistics
patrick@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

David L Lorenz wrote:

Hi,
 I ran into an interesting question from one of our users. He had an array
of about 3000 by 300 by 3. He tried to use apply to sum the last dimension:

result <- apply(array, c(1,2), sum)

 I'm not sure he was ever able to get the result.  He was surprised
because he could use apply over different dimensions and had no problem:

wrong.result <- apply(array, c(2,3), sum)

 I suggested that he simply break down the problem into a simple
summation:

result <- array[,,1] + array[,,2] + array[,,3]

 That executed very fast.

 My question is "Has anybody constructed a list of functions that do not
scale well under certain circumstances?"  I remember seeing something
within the last year about outer being very slow for long vectors and
clearly, there are some problems with apply.
 Thanks.
Dave


--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news






<Prev in Thread] Current Thread [Next in Thread>