I'm looking 开发者_如何学Cfor a smoothing algorithm which retains the same number of points. Does such an algorithm exist for smoothing? Every algorithm I've seen reduces the number of data points.
One possibility would be a moving average -- e.g., each output point is the average of the last 10 points. Obviously, with this the first few points aren't smoothed as much.
I suppose it depends on what you are trying to do. You could use spline interpolation, which is just a generalization of the idea of a moving average or box car filter. (Formally speaking, B-spline interpolation is equivalent to iterating a moving average as many times as the degree of the spline.)
However, the trade off is that the more smoothing you apply, the more information you throw out from your data. If you try to add back in more points by interpolating, it can create weird artifacts like Runge phenomenon:
http://en.wikipedia.org/wiki/Runge's_phenomenon
This is a tradeoff inherent in low pass filtering and there isn't much to do about it. As a result, you may actually be better off leaving those points out in the end anyway.
精彩评论