I am trying to derive the ODE version of the continuous exponentially-weighted moving average on Integral form given as such:
$m(t) = \frac{1}{w} \int_{-\infty}^{t} x(\tau)e^{-(t-\tau)/w} \,d\tau$
I assume I will need to combine the chain rule as well as the fundamental theory of calculus in order to turn this into:
$\frac{dm}{dt} = \frac{1}{w}x(t) - \frac{1}{w}m(t)$
However, I am not too sure how to do this. For example, my steps so far are:
- $\frac{d}{dt} m(t) = \frac{d}{dt} \frac{1}{w} \int_{-\infty}^{t} x(\tau)e^{-(t-\tau)/w} \,d\tau$
- $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{d}{dt}(x(\tau)e^{-(t-\tau)/w}) \,d\tau$
- $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w} + x(\tau) \frac{de^{-(t-\tau)/w}}{dt} \,d\tau$
- $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w}\,d\tau + \frac{1}{w} \int_{-\infty}^{t}x(\tau) \frac{de^{-(t-\tau)/w}}{dt} \,d\tau$
- $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w}\,d\tau + \frac{1}{w} \int_{-\infty}^{t}x(\tau) (-\frac{1}{w}) e^{-(t-\tau)/w} \,d\tau$
- $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w}\,d\tau + \frac{1}{w}(-\frac{1}{w}\int_{-\infty}^{t} x(\tau)e^{-(t-\tau)/w} \,d\tau) $
- $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w}\,d\tau - \frac{1}{w}m(t) $
- ...
However after 7. I am stuck trying to figure out why (and more importantly how):
$\frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w}\,d\tau = \frac{1}{w}x(t)$
I know that: $ \frac{d}{dt} \int_{-\infty}^{t} f(\tau) \,d\tau = \frac{d}{dt}F(t) - \frac{d}{dt}F(-\infty)$ However, I am not sure how this would apply here when we have $\frac{dx(\tau)}{dt}$ inside the integral since in this first integral term $e^{-(t-\tau)/w}$ is not differentiated because it already has been (chain rule).
Thank you in advance!
EDIT:
After looking into Leibniz Integral Rule, if I write it as such I get.
$\frac{d}{dt} \frac{1}{w} \int_{-\infty}^{t} x(\tau)e^{-(t-\tau)/w} \,d\tau$ -> set $x(\tau)e^{-(t-\tau)/w} = f(t,\tau)$ ->
$\frac{d}{dt} \frac{1}{w} \int_{-\infty}^{t} f(t,\tau) \,d\tau$ and solve as following using Leibnitz:
- $ \frac{d}{dt} \frac{1}{w} \int_{-\infty}^{t} f(t,\tau) \,d\tau = \frac{1}{w}f(t,t) + \frac{1}{w}\int_{-\infty}^{t} \frac{\partial}{\partial t}f(t,\tau) \,d\tau $
- $= \frac{1}{w}x(t)e^{-(t-t)/w} + \frac{1}{w}\int_{-\infty}^{t} \frac{\partial}{\partial t} x(\tau) e^{-(t-\tau)/w} \,d\tau$
- $= \frac{1}{w}x(t) + \frac{1}{w}\int_{-\infty}^{t} x(\tau) (-\frac{1}{w})e^{-(t-\tau)/w} $
- $= \frac{1}{w}x(t) - \frac{1}{w} m(t) $
Is this the correct way? Can we use the $\frac{\partial}{\partial t}$ straight on $e^{-(t-\tau)/w}$ and just treat $x(\tau)$ as constant when differentiation as done between steps 2 and 3?