[Rd] stats::convolve documentation enhancement
Michael Moers
mmoers at gmail.com
Tue Jun 25 21:07:36 CEST 2013
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(10000)
>> #length(x) + length(y) - 1 = 2^19
>> system.time(convolve(x, y, type="open"))
>>
>> # user system elapsed
>> # 1.17 0.02 1.18
>>
>>
>> #incorrect usage:
>> x <- rnorm(300000)
>> y <- rnorm(10000)
>> system.time(convolve(x, y, type = "open"))
>>
>> # user system elapsed
>> # 685.31 0.09 691.79
>>
>>
>>
>>
>> Thanks and Kind regards,
>> Michael Moers
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
More information about the R-devel
mailing list