šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

moving-median

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moving-median

Computes a moving median from an array of samples

1.0.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

moving-median

Computes a running median from a stream of values. Useful for filtering noisy signals.

Example

var createMedianFilter = require('moving-median')
var median = createMedianFilter(5)

var sequence = [1, 2, 5, 2, 1, 1, 1, 2, 1000, 2, NaN, 3, NaN, 3, 3]

for(var i=0; i<sequence.length; ++i) {
  console.log(median(sequence[i]))
}

Install

npm i moving-median

API

var median = require('moving-median')(windowSize)

Creates a new median filter

  • windowSize is the number of samples in the median

Returns A function which accepts samples

var m = median(sample)

Compute the running median of the last windowSize samples.

  • sample is the next sample to add

Returns The median of the last windowSize samples

License

(c) 2015 Mikola Lysenko. MIT License

Keywords

median

FAQs

Package last updated on 05 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts