Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to 'smooth' data and calculate line gradient?

I'm reading data from a device which measures distance. My sample rate is high so that I can measure large changes in distance (i.e. velocity) but this means that, when the velocity is low, the device delivers a number of measurements which are identical (due to the granularity of the device). This results in a 'stepped' curve.

What I need to do is to smooth the curve in order to calculate the velocity. Following that I then need to calculate the acceleration.

How to best go about this?

(Sample rate up to 1000Hz, calculation rate of 10Hz would be ok. Using C# in VS2005)

like image 650
paul Avatar asked Oct 15 '08 09:10

paul


People also ask

How do you smooth a data set?

There are different methods in which data smoothing can be done. Some of these include the randomization method, using a random walk, calculating a moving average, or conducting one of several exponential smoothing techniques.

How do you calculate the gradient of a signal?

Re: how to calculate the slope of a signal to find its peak Given two points on the line, (X,Y) and (X1,Y1) the formula for slope is (Y1-Y)/(X1-X).

What are smoothing techniques?

Smoothing techniques are kinds of data preprocessing techniques to remove noise from a data set. This allows important patterns to stand out. In market analysis, smoothed data is preferred because it generally identifies changes in the economy compared to unsmoothed data.

What other methods are there for data smoothing?

The random method, simple moving average, random walk, simple exponential, and exponential moving average are some of the methods used for data smoothing.


1 Answers

The wikipedia entry from moogs is a good starting point for smoothing the data. But it does not help you in making a decision.

It all depends on your data, and the needed processing speed.

Moving Average Will flatten the top values. If you are interrested in the minimum and maximum value, don't use this. Also I think using the moving average will influence your measurement of the acceleration, since it will flatten your data (a bit), thereby acceleration will appear to be smaller. It all comes down to the needed accuracy.

Savitzky–Golay Fast algorithm. As fast as the moving average. That will preserve the heights of peaks. Somewhat harder to implement. And you need the correct coefficients. I would pick this one.

Kalman filters If you know the distribution, this can give you good results (it is used in GPS navigation systems). Maybe somewhat harder to implement. I mention this because I have used them in the past. But they are probably not a good choice for a starter in this kind of stuff.

The above will reduce noise on your signal.

Next you have to do is detect the start and end point of the "acceleration". You could do this by creating a Derivative of the original signal. The point(s) where the derivative crosses the Y-axis (zero) are probably the peaks in your signal, and might indicate the start and end of the acceleration.

You can then create a second degree derivative to get the minium and maximum acceleration itself.

like image 198
GvS Avatar answered Nov 01 '22 15:11

GvS