【发布时间】:2014-04-10 02:13:52
【问题描述】:
我在这面前严重不知所措,R中的stats filter命令是做什么的,“卷积”方法是如何实现的。我理解过滤器为 1 的情况,但对于过滤器的任何其他值,事情会变得混乱。从 stackoverflow 中的另一个问题 (simple examples of filter function, recursive option specifically) 我了解了“卷积”对于 filter =1 的工作原理 例如:
f1<-1,f2<-1,f3<-1
x<-c(1:5)
filter(x,c(f1,f2))
3 5 7 9 NA
#which translates to
x[1]*f1+x[2]*f2
x[2]*f1+x[3]*f2
x[3]*f1+x[4]*f2
x[4]*f1+x[5]*f2
x[5]*f1+x[6]*f2 #x[6] is NA
#filter other than 1
#filter<-c(1,2)
filter(x,c(1,2))
4 7 10 13 NA
#and not the below ones
x[1]*f1+x[2]*f2=5
x[2]*f1+x[3]*f2=8
x[3]*f1+x[4]*f2=11
等等,这里到底发生了什么?这可能是微不足道的,因为缺乏对卷积方法的理解,但我无法弄清楚
【问题讨论】:
-
明确地说,这不是
Filter,而是stats::filter。也不是dplyr::filter
标签: r signal-processing