[Rd] stats::convolve documentation enhancement

2013-06-24 Thread Michael Moers
Hi,

the function stats::convolve does not mention efficient usage of the 
underlying FFT algorithm, such as

(a) if type="circular", then length(x)=length(y) should have many 
factors (e.g. length(x) = length(y) = 2^n)
(b) if type="open" or "filter", then length(x)+length(y)-1 should have 
many factors (e.g. length(x)+length(y)-1 = 2^n)

In particular the latter may not be obvious to first time users, who may 
think that stats::convolve is slow, even though it is fast, if applied 
correctly.

Moreover for zero padding, one may apply stats::nextn to (a) length(x) 
or (b)  length(x)+length(y)-1.


#Example:

#correct usage:
x <- rnorm(514289)
y <- rnorm(1)
#length(x) + length(y) - 1 = 2^19
system.time(convolve(x, y, type="open"))

#   user  system elapsed
#   1.170.021.18


#incorrect usage:
x <- rnorm(30)
y <- rnorm(1)
system.time(convolve(x, y, type = "open"))

#   user  system elapsed
# 685.310.09  691.79




Thanks and Kind regards,
Michael Moers

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] stats::convolve documentation enhancement

2013-06-25 Thread Michael Moers

Hi Hervé,

thank you for the link, I like the convolve2() function, it is 
definitely a more user-friendly version of convolve().


I still believe that convolve() would be worth improving for the R stats 
package, since it is pretty important in signal processing. I think it 
would be great to have a better convolution function.


Thanks and regards,
Michael

Am 24.06.2013 20:51, schrieb Hervé Pagès:

Hi Michael,

There are many issues with stats::convolve() that hopefully one day
will be addressed. Full story here:

  https://stat.ethz.ch/pipermail/r-devel/2007-February/044529.html

The user shouldn't have to worry about the lengths of the arguments:
convolve() should take care of doing the zero-padding internally so
it's always fast. That's what the proposed convolve2() does (in
addition to addressing a few other issues).

Cheers,
H.

On 06/23/2013 09:29 AM, Michael Moers wrote:

Hi,

the function stats::convolve does not mention efficient usage of the
underlying FFT algorithm, such as

(a) if type="circular", then length(x)=length(y) should have many
factors (e.g. length(x) = length(y) = 2^n)
(b) if type="open" or "filter", then length(x)+length(y)-1 should have
many factors (e.g. length(x)+length(y)-1 = 2^n)

In particular the latter may not be obvious to first time users, who may
think that stats::convolve is slow, even though it is fast, if applied
correctly.

Moreover for zero padding, one may apply stats::nextn to (a) length(x)
or (b)  length(x)+length(y)-1.


#Example:

#correct usage:
x <- rnorm(514289)
y <- rnorm(1)
#length(x) + length(y) - 1 = 2^19
system.time(convolve(x, y, type="open"))

#   user  system elapsed
#   1.170.021.18


#incorrect usage:
x <- rnorm(30)
y <- rnorm(1)
system.time(convolve(x, y, type = "open"))

#   user  system elapsed
# 685.310.09  691.79




Thanks and Kind regards,
Michael Moers

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel





__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel