2
$\begingroup$

Is there a linear filter whose step-response (or ramp-response) is an S-curve?

I think the properties I'm looking for here are (1) time-reversal symmetry, and (2) at least a continuous first derivative.

$\endgroup$

3 Answers 3

7
$\begingroup$

Sums of harmonic cosines

The Hann window is a sum of a rectangular function and a truncated cosine. As an impulse response it has the qualities you asked for:

Hann window as impulse response, and the corresponding step response
Figure 1. Hann window as impulse response, and the corresponding step response. The step response is valued $x - \frac{\sin(2\pi x)}{2\pi}$ over $0 \le x \le 1$, and is constant outside that range, because the impulse response is zero outside that range. The step response and its first two derivatives are continuous, because the impulse response and its first derivative are continuous.

A filter with Hann impulse response can be constructed as the (normalized) sum of a truncated integrator filter and the real part of the lowest-non-zero-frequency bin of a sliding discrete Fourier transform, both of which can be calculated recursively as truncated IIR filters.

The filters have poles on the z-plane unit circle (they are marginally stable) and require periodical refreshing of their state to cut accumulation of round-off errors. For fixed point input the truncated integrator can be implemented with extended bit depth so that no rounding errors accumulate and refreshing its state is not necessary.

Octave source for the composite filter:

r = 20;
w = 2*pi/r;
b0 = zeros(1, r+1);
b0(1) = 1;
b0(r+1) = -1;
a0 = [1, -1];
b1 = zeros(1, r+2);
b1(1) = -1; b1(2) = cos(w); b1(r+1) = 1; b1(r+2) = -cos(w);
a1 = [1, -2*cos(w), 1];
length = r+10;
impulse = eye(1, length);
ir = filter(b0, a0, impulse) + filter(b1, a1, impulse);
normalizationfactor = 1/sum(ir)
normalizationfactor = 1/r #Alternative calculation
ir *= normalizationfactor;
plot([0:length-1], ir, "o");

Impulse response from octave script
Figure 2. Hann impulse response from the first Octave script.

It is possible to get rid of the unnecessary one-sample delay without additional cost by multiplying the complex transfer function of the sliding DFT bin by $e^{-i\omega}$ before taking the real part:

r = 20;
w = 2*pi/r;
b0 = zeros(1, r+1);
b0(1) = 1;
b0(r+1) = -1;
a0 = [1, -1];
b1 = zeros(1, r+2);
b1(1) = -cos(w); b1(2) = 1; b1(r+1) = cos(w); b1(r+2) = -1;
a1 = [1, -2*cos(w), 1];
length = r+10;
impulse = eye(1, length);
ir = filter(b0, a0, impulse) + filter(b1, a1, impulse);
normalizationfactor = 1/sum(ir)
normalizationfactor = 1/r #Alternative calculation
ir *= normalizationfactor;
plot([0:length-1], ir, "o");

Undelayed Hann filter impulse response
Figure 3. Undelayed Hann impulse response from the second Octave script.

There are other window functions with harmonic cosine terms, and filters with them as impulse responses could be implemented similarly.

B-splines

Piece-wise polynomials such as B-splines are another alternative for the impulse response shape. Cascaded integrator–comb (CIC) filters can be used to implement them. A triangle function would be the minimal piece-wise polynomial function (and B-spline) to meet your demands. The implementation is very simple: A truncated integrator in cascade with an identical truncated integrator. This comes from the favorable property of B-spline functions that they are each a convolution of an impulse by rectangular function multiple times. The number of continuous derivatives is incremented by each convolution. The earlier notes about stability apply.

Triangle impulse response and the corresponding step respones
Figure 4. A triangle impulse response and the corresponding step response.

Octave source:

r = 20;
b = zeros(1, r+1);
b(1) = 1;
b(r+1) = -1;
a = [1, -1];
length = 2*r+10;
impulse = eye(1, length);
ir = filter(b, a, filter(b, a, impulse));
normalizationfactor = 1/sum(ir)
normalizationfactor = 1/(r*r) #Alternative calculation
ir *= normalizationfactor;
plot([0:length-1], ir, "o");

Octave script output
Figure 4. Triangular impulse response from the Octave script.

$\endgroup$
0
$\begingroup$

Gaussian filter has an response of (approximation of) gauss bell-curve, which is kind of S-shaped. Higher the order (of filter) = better the approximation of curve and better the symmetry. In my use case, 5th order was the lowest which worked good enough, but I was in analog. In digital, you may be less limited.

$\endgroup$
0
$\begingroup$

Hi: The step response of $y_{t} = \rho * y_{t-1} + \beta x_{t} + \epsilon_t$ for positive $\beta$ and $\rho$ between zero and one is an S-curve. It's called the koyck distributed lag in the time domain but I've never found a very nice discussion of it in the frequency domain. If anyone knows of one, the knowledge is appreciated. One reference discussing the frequency domain is below but I never found it all that enlightening.

https://alexsingleton.files.wordpress.com/2014/09/22-transfer-function-modelling.pdf

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.