26medias / timeseries-analysis

NPM Package - Timeseries analysis, noise removal, stats, ...
238 stars 48 forks source link

Reference for smoother() #13

Closed dieschnittstelle closed 5 years ago

dieschnittstelle commented 5 years ago

I really like this package! Currently, I am employing smoother() for smoothing data that will be presented in a research paper. For this purpose, it would be great to quote a reference for the algorithm that is implemented by smoother(). Does there exist any reference for it?

26medias commented 5 years ago

Hi,

I'm glad it's useful :)

I don't know of any reference for this algorithm. It's pretty simple so I'm most likely not the first one to come up with it.

The basic operation is an average between 3 points: point[x] = ( point[x-1] + point[x+1] ) / 2;

It pretty much ignores the value of the point in the middle and replaces it with the average of the 2 points that surrounds it. It then go forward one position and repeats the operation until the end of the dataset is reached.

This is then repeated multiple times in a row, progressively smoothing the dataset more and more. That number is controlled by the period option in the smoother() method.

If you use smoother({period:1}), then there is a single pass of the smoothing. If you use smoother({period:10}) you'll get 10 successive smoothing.

You can extract the noise out of your dataset (filtering the signals out) by first obtaining a smoothed dataset via smoother() and then simply subtracting the value of each datapoints in the original dataset with the value of the same datapoint in the smoothed data.

dieschnittstelle commented 5 years ago

... great, thanks a lot!