Computes a moving median from a stream of numerical values
MIT License
Computes a running median from a stream of values. Useful for filtering noisy signals.
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]))
}
npm i moving-median
var median = require('moving-median')(windowSize)
Creates a new median filter
windowSize
is the number of samples in the medianReturns A function which accepts samples
var m = median(sample)
Compute the running median of the last windowSize
samples.
sample
is the next sample to addReturns The median of the last windowSize
samples
(c) 2015 Mikola Lysenko. MIT License