【问题标题】:Working of stats::filter function Rstats::filter 函数 R 的工作
【发布时间】: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


【解决方案1】:

过滤器以反向时间顺序应用。所以第二个例子的第一个元素是:

x[1]*2 + x[2]*1 = 2 + 2 = 4.

等等

卷积的定义包括反转输入之一的顺序。

【讨论】:

  • 哦,粗鲁,我在上一个问题中的原始示例对于卷积示例实际上是错误的。返回我去编辑。
【解决方案2】:

测量蓝牙信标 ping 之间的时间差

使用统计过滤器的示例

其中 AP 是接入点,Location 是测量测试对象的位置

Location DateTime Access Point MAC RSSI
Lab@(15m) 2021-02-25 12:04:34 "1838Y-1282400000" "dc:0d:08:00:06:09" -76
Lab@(15m) 2021-02-25 12:04:34 "1838Y-1258500000" "dc:0d:08:00:06:09" -75
.Many more rows omitted.. ... ... ... ...
lab-loadingdock 2021-02-25 12:29:10 "1838Y-1282400000" "dc:0d:08:00:06:09" -73
lab-loadingdock 2021-02-25 12:29:13 "1838Y-1283400000" "dc:0d:08:00:06:09" -79
lab-loadingdock 2021-02-25 12:29:13 "1838Y-1258600000" "dc:0d:08:00:06:09" -86
lab-loadingdock 2021-02-25 12:29:13 "1838Y-1282400000" "dc:0d:08:00:06:09" -73
lab-loadingdock 2021-02-25 12:29:13 "1838Y-1258500000" "dc:0d:08:00:06:09" -64
lab-loadingdock 2021-02-25 12:29:15 "1838Y-1282400000" "dc:0d:08:00:06:09" -76
LabOffice 2021-02-25 13:07:06 "1838Y-1258500000" "dc:0d:08:00:06:09" -76
LabOffice 2021-02-25 13:07:06 "1838Y-1282400000" "dc:0d:08:00:06:09" -92

BLE_Beacon_data %>%
 dplyr::filter(AP=="1838Y-1283400000",Location=="lab-loadingdock")%>%
 pull(DateTime)%>%
 stats::filter(c(1,-1))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-21
    • 2022-06-13
    • 2021-12-31
    • 1970-01-01
    • 2013-11-06
    相关资源
    最近更新 更多