Skip to content

movingMedian function #24147

Open
Open
@gazpachoking

Description

@gazpachoking

Proposal:
Similar to movingAverage, there should be a function for movingMedian to filter out anomalous data points. There have been requests for such a function in multiple issues, but I still see no way to accomplish this.

EDIT: Or, even more flexible, a function like aggregateWindow, but that you specify a number of points rather than a time range. Such that movingWindow(fn: median, n: 3) would be the same as my proposed movingMedian(n: 3)

Current behavior:
You must window the data by time, rather than by number of data points to get a moving median.

Desired behavior:
A way to window data by number of points, or a movingMedian function to do the desired filtering directly.

Alternatives considered:
Use an aggregateWindow(every: 15m, period: 45m, fn: median) or something of that nature. This works depending on how regular your data points are, but it also leaves several windows at the beginning and end of the window which only had less than 3 points when the median function was applied.

Use case:
We have some sensors that occasionally emit a wrong data point which isn't in line with the rest of the values emitted by the sensor. Being able to grab the moving median of 3 points ensures we never do any calculations which use the spurious points.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions