Question

I am seriously at a loss in front of this, what does the stats filter command in R do how is the "Convolution" method implemented. I understand the case when filter is 1 but for any other value of filter things get confusing. From another question in stackoverflow (simple examples of filter function, recursive option specifically) I understood how "convolution" works for filter =1 eg:

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

and so on, what exactly is happening here? this might be trivial and because of the lack of understanding Convolution method, but I am not able to figure it out

Was it helpful?

Solution

The filter is applied in reverse time order. So the first element of the second example is:

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

etc.

The definition of a convolution includes reversing the order of one of the inputs.

OTHER TIPS

Measuring the time difference between Bluetooth beacon pings

Example using the stats filter

Where AP is the Access point, and Location is where the test object was measured from

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))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top