[Rd] stats::convolve documentation enhancement

Hervé Pagès hpages at fhcrc.org
Wed Jun 26 00:04:13 CEST 2013


Hi Michael,

On 06/25/2013 12:07 PM, Michael Moers wrote:
> 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.

I totally agree with that.

Cheers,
H.

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

-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the R-devel mailing list