对序列应用无限脉冲响应滤波器。Applies an Infinite Impulse Response filter on a series.

此函数接受一个包含动态数值数组的表达式作为输入,并应用一个无限脉冲响应滤波器。The function takes an expression containing dynamic numerical array as input, and applies an Infinite Impulse Response filter. 通过指定滤波器系数,可以将此函数用于:By specifying the filter coefficients, the function can be used:

  • 计算序列的累计和to calculate the cumulative sum of the series
  • 应用平滑操作to apply smoothing operations
  • 应用各种高通、带通和低通滤波器to apply various high-pass, band-pass, and low-pass filters

此函数的输入列包含由滤波器的 a 系数和 b 系数组成的动态数组和两个静/动态数组,并且此函数会对该列应用滤波器。The function takes as input the column containing the dynamic array and two static dynamic arrays of the filter's a and b coefficients, and applies the filter on the column. 它会输出新的动态数组列,其中包括滤波后的输出。It outputs a new dynamic array column, containing the filtered output.


series_iir(x, b , a)series_iir(x, b , a)


  • x:动态数组单元格(数值数组),通常是 make-seriesmake_list 运算符生成的输出。x : Dynamic array cell that is an array of numeric values, typically the resulting output of make-series or make_list operators.
  • b:一个常量表达式,其中包含滤波器的分子系数(存储为由数值组成的动态数组)。b : A constant expression containing the numerator coefficients of the filter (stored as a dynamic array of numeric values).
  • a:一个常量表达式,例如 b。a : A constant expression, like b . 包含滤波器的分母系数。Containing the denominator coefficients of the filter.


a 的第一个元素(即 a[0])不得为零,以避免除以 0 的现象发生。The first element of a (that is, a[0]) mustn't be zero, to avoid division by 0. 请查看下面的公式See the formula below.

滤波器的递归公式The filter's recursive formula

  • 假设输入数组为 X,系数数组 a 和 b 的长度分别为 n_a 和 n_b。Consider an input array X, and coefficients arrays a and b of lengths n_a and n_b respectively. 滤波器的传递函数(会生成输出数组 Y)的定义如下:The transfer function of the filter that will generate the output array Y, is defined by:
Yi = a0-1(b0Xi + b1Xi-1 + ... + bnb-1Xi-nb-1 - a1Yi-1-a2Yi-2 - ... - ana-1Yi-na-1)Yi = a0-1(b0Xi + b1Xi-1 + ... + bnb-1Xi-nb-1 - a1Yi-1-a2Yi-2 - ... - ana-1Yi-na-1)


计算累计和。Calculate a cumulative sum. 使用系数 a=[1,-1] 且 b=[1] 的 iir 滤波器:Use the iir filter with coefficients a =[1,-1] and b =[1]:

let x = range(1.0, 10, 1);
print x=x, y = series_iir(x, dynamic([1]), dynamic([1,-1]))
| mv-expand x, y
xx yy
1.01.0 1.01.0
2.02.0 3.03.0
3.03.0 6.06.0
4.04.0 10.010.0

将其包装在函数中的方法如下:Here's how to wrap it in a function:

let vector_sum=(x:dynamic)
  let y=array_length(x) - 1;
  toreal(series_iir(x, dynamic([1]), dynamic([1, -1]))[y])
print d=dynamic([0, 1, 2, 3, 4])
| extend dd=vector_sum(d)
dd dddd
[0,1,2,3,4] 10