# Is this a leaky integrator?

We have implemented a way of approximating a data set with the following lines of code based on the dx/dt of wikipedia of leaky integrator.

dy = -A * y_previous + C
y_current = y_previous + dy*delta_t


However, I am uncertain if we are allowed to call the following truly a leaky integrator. I was a bit confused how to get the general solution with Laplace transforms from the wikipage with this because of the delta_t in our implementation. I have to add that I am slightly familiar with Laplace, but not with z-transformations and I was told I needed this since it's discrete.

With delta_t being the difference in time between t_current and t_previous, which is a constant value. I think we may have created a leaky integrator due to delta_t being a constant, if I would for instance call delta_t $\alpha$ (alpha), C to x_t, and rewrite it a bit, it seems more similar to sources I found online (1, 2, 3):

$y_t = y_{t-1} + (-Ay_{t-1} + C)\Delta t \\y_t = y_{t-1} -Ay_{t-1}\Delta t + x_t\Delta t \\\Delta t = \alpha \\C = x_t \\y_t = (1-A\alpha) y_{t-1} + \alpha x_t$

So then with the z-transform I have determined the transfer function:

$y_t = (1-A\alpha)y_{t-1} + \alpha x_t \\Y(z) = (1-A\alpha)z^{-1} + \alpha X(z) \\\frac{Y(z)}{X(z)}((1-A\alpha)z^{-1} + 1) = \alpha \\ \\ H(z) = \frac{\alpha}{1-(1-A\alpha)z^{-1}}$

My questions are:

1. Is in this case indeed the delta_t kind of $\alpha$ similar to the cited sites?
2. So is this indeed a leaky integrator?
3. What can I say about the values A and $\alpha$ can be for stability of the leaky integrator? Should indeed hold:

$A\alpha<0$

Yes this is indeed what is referred to as a “leaky integrator”, as the discrete time approximation of such a device. The key element that makes it “Leaky” is having the positive real pole at $$z < 1$$ which is the equivalent of a continuous time real pole along the negative real axis.

With the pole at $$z=1$$, (and a zero at $$z=0$$) we get the discrete time approximation of a pure integrator, this is an accumulator with the transfer function given as:

$$H(z) = \frac{z}{z-1}$$

Any other constants added are gain scaling, but this represents an “integrator” equivalent as the impulse invariant mapping of $$H(s) = 1/s$$.

As we move the pole off of $$z=1$$ As given by:

$$H(z) = \frac{z}{z-\alpha}$$

With $$\alpha$$ as an arbitrary real constant between 0 and 1 (not using OP’s $$\alpha$$ but generally), it becomes a “leaky integrator” with $$\alpha$$ as the damping factor: the closer $$\alpha$$ is to 1, the less the “leak”. Any other constant as before is just a scaling factor.

As noted, this is the discrete time equivalent to moving the pole on the s-plane from $$s=0$$ that we get with $$H(s) = 1/s$$ into the left half plane to be:

$$H(s) = \frac{1}{s+ 1/\tau}$$

Where $$\tau$$ is the time constant indicating a decay given by $$e^{-t/\tau}$$ which comes directly from the inverse Laplace Transform of $$H(s)$$.

• Thank you so much for your elaborate response! If I may ask another question, would it still be a leaky integrator if the delta_t was varying over t_1 to t_N, in other words not a constant? May 18, 2023 at 12:08
• Is your delta_t varying such that you don't have a consistent sample rate, or is it more that the sampling rate varies over the longer term duration? In either case changing delta_t simply changes $\alpha$ and similarly the time constant $\tau$, which just means the bandwidth or leak rate is modified accordingly-- but it is still a leaky integrator as long as the $\alpha$ you end up with has a value between 0 and 1 not including either. May 18, 2023 at 12:23