# Resampling n timeseries datasets with different sampling frequencies

I am currently working on an IoT project that uses datasets from different sensors with differing sample rates fs = (1s, 30s,...). I combine this with API data fs = (1min, 15min, 30min, ...). In other words, I have multiple signals coming in with differing fs. I want to process this data in ways that require the same fs across all datasets, ie System Identification.

My main question is: is there a convention for resampling 'n' time-series datasets with different fs?

My current approach is:

1. Get the list of datasets
2. Find the highest sampling frequency
3. Resample all datasets based on this sampling frequency

But my intuition is telling me this isn't the best approach.

Theoretically, what you are doing seems correct as long as resampling operation is done properly. Let's say the sample rate of one of the $$i$$th input signal $$x_{i}[n]$$ is $$F_{s,i}^{(in)}$$ and the target sample rate is $$F_{s} = \max_{i}F_{s,i}^{(in)}$$. Let $$\frac{F_{s}}{F_{s,i}^{(in)}} = \frac{L}{M}$$ where $$L,M$$ are the upsampling and downsampling factors, respectively. So the resampling procedure should be done according to the block diagram below

where $$h$$ is the anti-imaging anti-aliasing filter with the normalized cutoff frequency $$\omega_{c} = \frac{\pi}{\max(L,M)}$$. In MATLAB with Signal Processing Toolbox, you can simply run yi = resample(xi,Fs,Fsi).

Having said that, resampling to a higher sample rate increases the signal lengths and in turn imposes constraints on computational resources at your disposal. So you may want to reconsider resampling to the highest sample rate. For example, if your application is deep learning and you extract features from the signals, you may not need to do resampling.

In case you still need to do resampling, to avoid increasing all signal lengths, you may want to measure the maximum bandwidth of the signals you acquire and change the sample rate to the Nyquist rate corresponding to that bandwidth $$B$$ (and in case you need some oversampling, consider $$F_{s} = 8B$$ to have an oversampling by a factor of 8, for example).

Another point to consider is when $$F_{s,i}^{(in)}$$ is close to the target sample rate $$F_{s}$$. In that case, you may benefit from Farrow sample rate conversion algorithm.

• Quality answer, thank you! My application is time-series forecasting & model discovery, and I hadn't considered your points on bandwidth or Farrow sample rate. Commented May 24 at 14:43
• Elaborating on the "close" point: even two sample rates that are nominally the same are NOT the same unless they are phase locked. So you may have to synchronize the individual clocks by identifying specific events in the streams. This would require irrational sample rate conversion (resample() can't do that) . The standard algorithm for this is a polyphase with phase interpolation. The Farrow structure is a memory efficient way of implementing this, but if you are not pressed for memory, I wouldn't bother as its complicated and not as good. Commented May 24 at 17:03
• Thanks for the pointer @Hilmar, you raise some interesting points. Can you point me in a direction to learn more about the relationship between sample rates and phase locking? Commented May 24 at 17:22
• @sebzuddas: here is a quick explanation of the issue: community.arm.com/support-forums/f/embedded-forum/311/… Commented May 24 at 18:01