26medias / timeseries-analysis

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

Method author? #4

Closed DDAGitHub closed 7 years ago

DDAGitHub commented 7 years ago

Hello! Please, tell me who is the author or what is the "official" name of the "Iterative Noise Removal" method. Or may be it is the modification of other method?

With best regards, Dmitry.

26medias commented 7 years ago

Hi,

This type of algorithm is apparently called a multi-pass moving average by convolution.

I built the algorithm myself. It's a pretty simple recursive algo. Each point in the output chart is the recursive average of its previous and next point:

Loop X times: For each point in the chart, except for the first and last one: point[n] = (point[n-1]+point[n+1])/2;

X is the "period" parameter of the algorithm. For example, if you were executing xxx.smoother ({period:5}) then the chart would be smoothed 5 times in a row.

The 1st and last points are always equal to their corresponding value in the input data.

That algorithm provides the best possible smoothing I could ever obtain, but because of the way that algorithm works, any new slight change in an point of the chart will affect the entire output. That also means that it's a smoothing method you can't use on dynamic data like the stock market for example, because the smoothing would continually change, so you wouldn't be able to use its output in algorithmic trading for example.

But on static data, it is performing much better than a regular moving average or even a multi-pole smoothing filter, as it has no lag and a very fast response time.

Another description of a similar algorithm: http://www.analog.com/media/en/technical-documentation/dsp-book/dsp_book_Ch15.pdf

In my algorithm, I ignore point[n] in the calculation and only include its neighbors, contrary to a regular moving average by convolution where they take the current point in consideration in the calculation. Mine seems to have a faster response time but both are pretty much equivalent in the output.

DDAGitHub commented 7 years ago

Thank you very much!