# How to implement a filtered derivative

**URL:** <https://discourse.julialang.org/t/how-to-implement-a-filtered-derivative/109441>\
**Category:** Signal and Image Processing\
**Tags:** question\
**Created:** [January 30, 2024, 10:49am UTC](https://discourse.julialang.org/t/how-to-implement-a-filtered-derivative/109441 "2024-01-30T10:49:38Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 30, 2024, 6:12pm UTC](https://discourse.julialang.org/t/how-to-implement-a-filtered-derivative/109441/9 "2024-01-30T18:12:41Z")

</div>

> [@ufechner7](#):
>
> My input is a time series of wind turbine speed measurements, which could be real values or results of a simulation. A time series with 500000 values. I have the speed and want to calculate the acceleration.

The formula you quote corresponds a first-order IIR filter. Is there a reason why you want to use this particular filter, vs. a finite difference filter (= FIR filter, as in [your other recent thread](https://discourse.julialang.org/t/how-to-implement-lyons-differentiator/109438)) in conjunction with smoothing (low-pass filtering) to reduce noise, or a higher-order IIR filter, or …?

In general, filter design is very context dependent. How noisy is your data? Over what bandwidth do you need to be accurate? How will it be implemented, and how efficient does it need to be?

If you have 50000 points that you need to approximately differentiate in Julia, that is a very small-scale problem where efficiency doesn’t sound like a primary concern (as opposed to something that needs to operate continuously in an embedded system). So if I were you, I would implement something straightforward that you can _understand completely_, e.g. smoothing followed by a finite-difference approximation, instead of trying to copy formulas whose properties you don’t really understand.

But if you want to learn more, I would pick up a textbook on discrete-time signal processing and start by understanding IIR and FIR filters. They are _extremely simple_ to implement once you understand them (and the DSP.jl package, for example, can [do this for you](https://docs.juliadsp.org/stable/filters/#Filter-application)) — the hard part is designing the filter weights for a particular application.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-implement-a-filtered-derivative/109441)._
