2

Consider a simple linear, time invariant system of the form:

y_k = c*y_k-1 + (1-c)x_k

The impulse response of this system can be computed by either dimpulse or by applying lfilter to a vector composed of a one followed by zeros:

import scipy.signal as sp_signal
import numpy as np

Ts = 1
c = 0.9
A = [1, -c]
B = [1-c]

time, imp_resp1 = sp_signal.dimpulse((B, A, Ts))

x = np.zeros(100)
x[0] = 1
imp_resp2 = sp_signal.lfilter(B, A, x)

print(imp_resp1[0][:5,0])
print(imp_resp2[:5])

which yields:

array([ 0.    ,  0.1   ,  0.09  ,  0.081 ,  0.0729])

[ 0.1      0.09     0.081    0.0729   0.06561]

Why does dimpulse introduce a one-sample delay in the impulse response?

rhz
  • 960
  • 14
  • 29

1 Answers1

0

Observe that if you add a zero to the numerator, i.e. [1-c, 0] dimpulse will give the same result as lfilter. Adding this zero should not do anything at all so I suspect a bug of some sort.

adr
  • 1,731
  • 10
  • 18