# Moving Average for Unevenly Sampled Time Series

If a time series is unevenly spaced, the simple moving average is not the best option to smooth it out (the window will be larger or narrower depending on the time distance of the events within that interval). Which method would you suggest that can be implemented when the time sampling of data is not constant?

• Perhaps use an adaptive window lenght that is determined by the actual time intervals between points rather than the number of points in a window. – Richard Hardy Oct 16 '17 at 16:19
• Right, but then the number of points per window would vary dramatically, affecting the analysis. – Angela Oct 20 '17 at 9:35
• If my proposal had no effect, I would not have proposed it. The question is what makes sense, not whether the analysis gets affected. Note that what StephanKolassa suggested is very much in the same spirit. There is no way around the fact that the points are unevenly distributed. In the sparse regions, there is little information, period. – Richard Hardy Oct 20 '17 at 10:04
• By following Stephan's suggestion I can keep the same number of points per window and give them just a different weight. On the other hand, if I implement your suggestion, I would have a very different number of points per window, which, yes, would affect my analysis. With that I mean it would not make sense for the purpose of my work. – Angela Oct 20 '17 at 10:31
• OK, I should explain the connection that seemed obvious to me. By Stephan's suggestion, you keep the same number of points with some weighting scheme (e.g. triangular). By my suggestion, you keep the same number of points with a particular weighting scheme: the points too far away in time get a weight of zero, the other ones get a weight of one over the number of such points. – Richard Hardy Oct 20 '17 at 13:36

• Thank you! I have just find out that it should be easy to do that in Matlab with : tsmovavg(vector,'w',weights,dim) – Angela Oct 20 '17 at 9:40