# 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!

-
I think this question would be more suitable for the quantitative finance community: quant.stackexchange.com – Andrey Rekalo Feb 13 '11 at 17:14
What makes you think that the underlying signal is differentiable? If it isn't, then why are you trying to find its derivative? it might be more appropriate to look at the average rate of change of the exchange rate over some fixed period of time. If that period is reasonably long compared to time between samples, then it should be relatively easy to get a smoothed average rate of change of the exchange rate. Another question you should probably be asking yourself is what significance the volume numbers have. – Brian Borchers Feb 13 '11 at 17:18
Thank you for your comments. I will think it over. – Grönwall Feb 13 '11 at 21:03

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.

-

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

-

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
-