Hi
[EMAIL PROTECTED] napsal dne 03.09.2008 16:39:07:
Dear list,
I'm wondering how to optimize functions/processes like the one shown
below (which simplifies something we're trying to do with very large
datasets).
In many cases I've noticed that using apply, sapply etc can help
speeding
Petr Pikal wrote:
Hi
[EMAIL PROTECTED] napsal dne 03.09.2008 16:39:07:
In many cases I've noticed that using apply, sapply etc can help
speeding up processes, but in this case I don't see how I could do so.
a - runif(1000,0.5,1.6)
C - 2
M - 1000
system.time( for (i
Dear Uwe, Petr and Berend,
Thank's a lot !!
I just checked and it's
c(cumprod(a)[M-1],cumprod(a[-1])[M-1]))
that gives an identical result to the my initial loop (at 10x speed of
my initial loop ... )
Wolfgang
Berend Hasselman a écrit :
Petr Pikal wrote:
Hi
[EMAIL PROTECTED] napsal
Note:
n - 100;
x - rnorm(n);
t1 - system.time({
xp - prod(x);
xpA2 - xp/x[n];
xpB2 - xp/x[1];
});
is calculating the product only once and is *constant in memory*.
With the suggest approach you are not only calculating the same thing
twice but you are also allocating a lot of memory,
4 matches
Mail list logo