hampel-filter

1.0.0 • Public • Published

Hampel filter

Build Status dependencies Status devDependencies Status License: MIT

Hampel filter implementation for removing outliers from time series data.

For Hampel filter details see:

API

hampelFilter(timeseriesData[, options])

timeseriesData

Time series data must be an array of numbers. For example:

[1, 2, 1, 1, 40, 2, 1, 1, 30, 40, 1, 1, 2, 1]

options

If you don't provide an options object then the following defaults will be used:

{
  windowHalfWidth: 5,
  threshold: 3,
  constantScaleFactor: 1.4826,
}

identifyOutliers(timeseriesData[, options])

timeseriesData

Time series data must be an array of numbers. For example:

[1, 2, 1, 1, 40, 2, 1, 1, 30, 40, 1, 1, 2, 1]

options

If you don't provide an options object then the following defaults will be used:

{
  windowHalfWidth: 5,
  threshold: 3,
  constantScaleFactor: 1.4826,
}

Installation

Using npm:

npm i -s hampel-filter

Usage

In Node.js

const { hampelFilter, identifyOutliers } = require('hampel-filter');

const data = [1, 2, 1, 1, 40, 2, 1, 1, 30, 40, 1, 1, 2, 1];

const filteredData = hampelFilter(data, { windowHalfWidth: 3 });
const outliers = identifyOutliers(data, { windowHalfWidth: 3 });


console.log('Initial data:', data);
// filteredData = [1, 2, 1, 1, 1.5, 1, 1, 1, 1, 1, 1, 1, 2, 1]
console.log('Filtered data:', filteredData);
// outliers = [4, 5, 8, 9]
console.log('Identified outliers:', outliers);

License

MIT © Dmitry Ilin

Package Sidebar

Install

npm i hampel-filter

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

8.15 kB

Total Files

5

Last publish

Collaborators

  • dmitry.ilin