From mmoers at gmail.com  Tue Jun 25 21:07:36 2013
From: mmoers at gmail.com (Michael Moers)
Date: Tue, 25 Jun 2013 21:07:36 +0200
Subject: [Rd] stats::convolve documentation enhancement
In-Reply-To: <51C8954C.2050802@fhcrc.org>
References: <51C72286.8050405@gmail.com> <51C8954C.2050802@fhcrc.org>
Message-ID: <51C9EA78.10707@gmail.com>

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
>>
>



[Rd] stats::convolve documentation enhancement
Michael Moers