frequency - 在时间序列数据中应用巴特沃斯过滤器
问题描述
我有以毫秒 (ms)(69300 行)为单位测量的时间序列数据,我想应用低通、高通和带通巴特沃斯滤波器。
我的方法如下:
- 将 ms 转换为 Hz
- 找到采样率/2 的奈奎斯特(作为采样率,我采用转换后的 Hz 值)
- 计算正弦曲线+噪声
- 计算低通和高通滤波器的截止频率(取总赫兹的 0.1 并除以低通的奈奎斯特值,并取总赫兹的 0.25)
- 对于带通滤波器,我计算截止频率的差异
- 应用过滤器的 -n 阶
- 通过正弦+噪声的滤波器。
下面是我使用 R 制作的代码片段:
# 69300 ms are 0.014430014430014Hz
x <- 1:69300
nyquist <- 0.014430014430014/2 # sampling rate/2
x1 <- sin(2*pi*RF*0.014430014430014) + 0.25*rnorm(length(RF))
# 0.014430014430014 Hz sinusoid+noise, RF is the time series metric
f_low <- 0.001443001/nyquist # 0.1 of total Hz divided by Nyquist
f_high <- 0.003607504/nyquist # 0.25 of total Hz divided by Nyquist
bf_low <- butter(4, f_low, type="low")
bf_high <- butter(4, f_high, type = "high")
bf_pass <- butter(4, 0.3000001, type = "pass") # f_high - f_low
b <- filter(bf_low, x1)
b1 <- filter(bf_high,x1)
b2 <- filter(bf_pass,x1)
这是正确的方法吗?应该代替 sinusoid+noise 将过滤器应用于度量本身吗?
解决方案
推荐阅读
- visual-studio-code - 如何在 vs-code 上禁用 [abc] 建议?
- c# - 列表列表的 Where 子句
- sql - 如何仅旋转选定的行数
- css - 如何用钩子覆盖材质 ui 样式
- angular - Angular 6 可观察和订阅
- html - Bootstrap 折叠和手风琴向侧面打开,而不是在下面
- python - 如何在 python 的 SPARQLWrapper 中创建参数化查询
- node.js - 计算nodejs中的cpu使用率
- ios - JSONSerialize 并将 JSON 发布到 Swift 中的服务器
- angular - *ngIf = "true" 应用于表单时无法访问表单数据