Smoothing 3D Data for the Second Derivative

I am not a signal processing expert and my feeble attempts at solving this problem have come up short.

I have a C++ application which is being fed regularly-spaced (in time) 3D position samples. The samples are generally accurate and, if plotted, appear to be quite smooth. However, when the second derivative is computed (to look at accelerations), there are occasional/rare spikes in the data which are unreasonable. (I know the general range of possible accelerations. And by "rare", I mean that over about two ours of data, I generally see less than a dozen spikes which are out of the realm of possibility.) I want to do as little to the data as possible, but smooth it enough to remove the spikes.

My first attempt was to use a Kalman filter in our math library. This removed the spikes, but changed the data far more than what I would really want and seems heavy-handed for what I need.

There seem to be a lot of options out there for 2D data, but I don't have enough signal processing background to understand the trade-offs or necessarily what might translate well to 3D data. Any education or suggestions would be appreciated!

• Welcome to DSP.SE! Can you share some example data (real or simulated)? That might help us answer you. The Kalman Filter should do what you want. Have you tried changing the noise variances (process and measurement) ? Sometimes thinking of the Kalman Filter as a tunable box with two knobs: how much the signal should change (process noise) and how well you can measure it (measurement noise) is better than making those parameters equal the real system. Also, what options are there for 2D? Please add that to your question, we might be able to point to extensions that work for 3D data.
– Peter K.
Nov 13, 2015 at 14:32
• Unfortunately, I cannot share any of the data. For the Kalman filter, I have tried tuning it, but what I see is that it either doesn't do enough or does too much. And since the data is "generally" very well behaved, I don't want to modify the data any more than necessary. Looking around, I considered a least-squares fit, but that seems to be a 2D solution. And I am not sure that best fits the problem. Ideally, I think I just want to adjust points around the outliers and leave the rest of the data untouched.
– DiB
Nov 13, 2015 at 15:05
• And for more clarification, I would be happy with some suggestions on algorithms to consider. I am just not sure what is out there that is reasonably applicable to this type of smoothing.
– DiB
Nov 13, 2015 at 15:34