Properly average irregular samples into discrete regular ones

727 Views Asked by At

Imagine you have a device collecting data at not very regular time intervals. For plotting on graph or further processing, you'll want to turn the samples in regular ones, with constant time intervals:

enter image description here

The problem is not as easy as it may seem. You can't just average the point values in the neighbouring columns:

image description

Imagine such situation:

image description

Obviously, the real average is more influenced by the points closer to our sample time:

image description

I've been thinking quite hard about it. Someone suggested linear interpolation. But as you can see in the images, linear interpolation is not what we really can apply on scattered points. But it gave me this idea:

image description

Ok, I overcomplicated the image. What I mean is that I can interpolate every two points on the opposing sides of our time and make average out of intersections between the interpolation and our offsetted Y axis. Let's try it on the image we used with normal averaging:

image description

Yes, I think this looks much more right. But common sense doesn't allways work with math, which is why I'm posting here.

  1. Is my idea correct? Can I improve it? Did I take the wrong path?
    • if it actually is right, I am missing the approach for generating average when you have points on only one side.
  2. How could I go about calculating these? I think there must be a way without actually calculating line intersections - the Y is constant...
2

There are 2 best solutions below

0
On

I've been toying with different implementations of weighted averages using (what would in your case be) the difference between your discrete time and your sample times. I'm still working on finding a good solution, but some papers that might help:

Comparison of correlation analysis techniques for irregularly sampled time series http://www.nonlin-processes-geophys.net/18/389/2011/npg-18-389-2011.pdf

A Framework for the Analysis of Unevenly Spaced Time Series Data http://www.eckner.com/papers/unevenly_spaced_time_series_analysis.pdf

A Note on Trend and Seasonality Estimation for Unevenly-Spaced Time Series www.eckner.com/papers/trend_and_seasonality.pdf

0
On

I would recommend Kriging as a statistically valid approach to interpolate between samples, followed by discretization at the desired time intervals. The advantage to this is twofold: first, this method permits estimation at any time point, thus we can choose the frequency and phase of the time points to be estimated. Second, we also get the variance of the estimate, not just the point estimate itself.

As the implementation of this method is available in a number of different software packages, I will refrain from describing the mathematics in more detail.