Estimating the derivative of a noisy, non-uniformly sampled function I have some trading data in the form of (exchange rate, volume, time) tuples. I'm trying to estimate the rate of change of the exchange rate. Of course the trade data is non-uniformly sampled.
Also, the function is rather noisy, so the estimation has to be robust.
So what are good ways of estimating the derivative of a noisy, non-uniformly sampled function?
Thanks!
 A: The magic words are: "Kalman filter" (this solves this problem in a relatively simple setting, there are a number of extensions, many of them proprietary). The wikipedia article on Kalman filtering, and the references therein, is a good place to start.
A: The exchange rate is not exactly a continuous-time signal. It is updated at discrete time instants and, therefore, it seems more natural to model it as a discrete-time signal, imho. What exactly does "noisy" even mean in this context? I assume you meant to say that the signal contains significant high-frequency content.
The first thing you might want to do is to use interpolation to obtain a discrete-time signal that could be thought of as the uniform sampling of a continuous-time signal. Then, you can use a smoothing filter (e.g., moving average) to remove the high-frequency content. Beware that causal smoothing filters introduce a delay. Then, once the high-frequency content has been removed, you can use a discrete-time differentiator to obtain an estimate of the derivative of the continuous-time signal that we imagine to be the originator of the time-series.
Books you might want to take a look at:
The Scientist and Engineer's Guide to Digital Signal Processing
A First Course on Time Series Analysis
A: There's a writeup on estimating derivatives at 
http://www.gregstanleyandassociates.com/whitepapers/FaultDiagnosis/Filtering/Derivative-Estimation/derivative-estimation.htm
 ..
Briefly, you could do least squares curve fits - that doesn't require equal sample intervals, although it does rule out the Savitzky-Golay filters mentioned there. Another approach is to do what is at the heart of the MACD calculation used in stock analysis.  The trick is to use two exponential filters, with different time constants, and subtract the difference between them.  The details are given in the above reference.  The details of the exponential filter are given in the the Filtering section, at 
http://www.gregstanleyandassociates.com/whitepapers/FaultDiagnosis/Filtering/filtering.htm 
 .. 
The typical exponential filter equations you see are based on equal time intervals.  However, that is not required.  Instead, think of these filters as the analog equivalent with a time constant tau (it matches the exponential filter at the time steps).  At each time step, calculate the difference in time since the last sample.  From that, calculate the filter constant "a" in digital form from the formula given in terms of the time constant tau.


*

*Greg Stanley 

