# Interpolating irregularly missing data points of regularly spaced data

If I have a set of regularly spaced sample data (spacing $\delta x$) and some of my data is missing (zero) but not at regular intervals, i.e.

$[a_0, (missing), (missing), (missing), a_4, a_5, (missing), a_7, a_8, a_9, a_{10}, ...]$

Can digital signal processing techniques be used to interpolate the missing data?

I've only read of interpolating by a FIR or IIR when the missing data is every nth element.

There is a lot more data present than missing.

The interpolation can be done offline.

The first or last data point(s) might be missing.

If you want to have just a working example, you can consider the functionality of scipy.interpolate:

N = 128
n = np.arange(N)
x = np.sin(2*np.pi*n/32)
plt.plot(n, x)

pos = np.random.randint(N, size=(50,))

import scipy.interpolate

plt.plot(n, interpolated(n), 's')


This code generates a signal x for n=0,...,127. Then, it deletes some values out of it and interpolates the missing values by spline cubic interpolation. See that the blue vertical lines denote the received samples, the green squares denote the interpolated values. The approximation is quite good.

• That looks good enough for my purposes, does it cope with data at the start or end being missing? – keith Mar 14 '17 at 12:25
• According to the scipy documentation for interp1d (where the server currently appears to be down for me), there is the parameter fill_value='extrapolate' to yield values outside of the sampling points. It's available after version 0.17 (which I don't have here, so I cannot try this out) – Maximilian Matthé Mar 14 '17 at 12:31
• Nice demo @MaximilianMatthé, I didn't realize the scipy interpolate handled this case so well! – Dan Boschen Mar 14 '17 at 16:49

I found a method similar to the zero-padding FFT interpolation but in which the missing samples can be nonuniformly spaced. I think it exactly solves the problem you have. The method is described here:

J. Selva, "FFT interpolation from nonuniform samples lying in a regular grid", IEEE Trans. on Signal Processing, vol. 63, n. 11, June 2015.

The code is available here.

Use inpainting method. Check this question. Inpainting methods also work for 1D signals.

• I didn't know about inpainting so that's good to learn, although the technique is a bit computationally heavy for my needs - thanks though. – keith Mar 15 '17 at 9:48