tags:

views:

351

answers:

3

Hi This is a bit of a longshot.
Suppose I am sampling signal at a fixed rate (say once per second).
Is there mathematical Java Library I can use to calculate/extract the following metrics from the sampled data?
1) The rate of change of the signal
2) An extrapolation/prediction of what the signal value will be in X seconds/minutes time
Thanks

+2  A: 

The rate of change is just the slope of the last two points, you don't need a library for that.

The 'prediction' you ask for is not rigorously defined, so I can only guess what you're after. There are many perfectly valid methods of doing this, from simple linear extrapolation (i.e. draw a line using the slope of the last two points however long you want to predict), to a Kalman filter.

OpenCV has routines for applying Kalman filters, though it's written in C. There's some interest in using it with Processing, so you might have luck following this guide:

http://ubaa.net/shared/processing/opencv/

I don't mean to beat a dead horse, but like so many questions, it might be helpful if you give more detail about what you're trying to do in order to get a better answer. Hope this helps!

Rooke
+2  A: 

1) The rate of change of the signal

You can easily calculate the rate of change of the signal with respect to time by either differencing or doing a polynomial fit and differentiating. You might also want to think about some sort of time averaging, because differentiation tends to make functions "jumpier", since the continuity is one order less than the function from which it's calculated.

2) An extrapolation/prediction of what the signal value will be in X seconds/minutes time

Once you have the answer to the first part, it's an easy matter to extrapolate. Just beware - extrapolation is always a dangerous thing, especially if the derivative is changing rapidly in time. Some sort of smoothing, averaging, or filtering is your friend here.

Another approach might be to take an FFT and do a term-by-term differentiation of the result.

duffymo
A: 

If you need some equations you can look at

Object-Oriented Implementatin of Numerical Methods by Didier Besset. http://www.amazon.com/Object-Oriented-Implementation-Numerical-Methods-Introduction/dp/1558606793/ref=sr_1_1?ie=UTF8&s=books&qid=1257821447&sr=8-1

This is mainly for your second part, as, depending on how you want to predict you may need various equations to get a better idea, if you are trying to do a best fit, then extend.

For the first part, I think that has been sufficiently dealt with, determine the slope.

James Black