series_fir
This page explains how to use the series_fir function in APL.
The series_fir function applies a Finite Impulse Response (FIR) filter to a numeric dynamic array (series) using a specified filter kernel. This function performs digital signal processing operations such as smoothing, noise reduction, and frequency filtering on time series data.
You can use series_fir when you want to apply signal processing techniques to your time series data, such as smoothing noisy data, removing high-frequency noise, or implementing custom filtering operations. This is particularly useful for preprocessing data before analysis, removing artifacts, or extracting specific frequency components. Typical applications include sensor data processing, financial time series analysis, and performance monitoring where noise reduction is important.
Usage
Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
array | dynamic | A dynamic array of numeric values representing the input signal. |
kernel | dynamic | A dynamic array of numeric values representing the FIR filter coefficients. |
Returns
A dynamic array representing the filtered signal after applying the FIR filter.
Use case examples
In log analysis, you can use series_fir to smooth noisy request duration data using a moving average filter, which helps identify underlying performance trends.
Query
Output
| id | durations | smoothed_durations |
|---|---|---|
| u123 | [100, 120, 110, 130, 105] | [100, 110, 110, 115, 115] |
| u456 | [150, 140, 160, 135, 145] | [150, 145, 150, 147.5, 144] |
This query applies a 5-point moving average filter to request durations, useful for smoothing out noise and identifying underlying performance trends.
In OpenTelemetry traces, you can use series_fir to smooth noisy span duration data using a low-pass filter, which helps identify consistent latency patterns.
Query
Output
| service.name | durations | smoothed_durations |
|---|---|---|
| frontend | [100ms, 120ms, 110ms, 130ms] | [100ms, 110ms, 110ms, 115ms] |
| product-catalog | [50ms, 60ms, 55ms, 65ms] | [50ms, 55ms, 55ms, 60ms] |
This query applies a 4-point moving average filter to span durations, useful for smoothing out noise and identifying consistent latency patterns across services.
In security logs, you can use series_fir to smooth noisy request duration data using a high-pass filter to detect anomalies while removing baseline noise.
Query
Output
| status | durations | filtered_durations |
|---|---|---|
| 200 | [100, 120, 110, 130, 105] | [-2, 2, 4, 2, -2] |
| 500 | [200, 220, 210, 230, 205] | [-2, 2, 4, 2, -2] |
This query applies a high-pass filter to request durations grouped by status code, useful for detecting anomalies while removing baseline noise in security analysis.
List of related functions
- series_fft: Performs Fast Fourier Transform on a series. Use for frequency domain analysis before applying filters.
- series_ifft: Performs inverse FFT to convert frequency domain back to time domain. Use after frequency domain filtering.
- series_fill_linear: Fills missing values using linear interpolation. Use for data preprocessing before filtering.
- series_abs: Returns the absolute value of each element in an array. Use for analyzing filter output magnitudes.
- series_cos: Returns the cosine of each element in an array. Use for generating filter kernels or analyzing periodic components.