0
$\begingroup$

I learned how to solve difference equation

$y(n) = (0.85)y(n-1) + x(n)$

using z Transform, and inverse z Transform, I get

$h(n) = 0.85^n u(n)$

where $u(n)$ is unit step sequence. Now my question is how do I use this solution on my data? I have

[  4.   3.   2.   8.   4.   4.  10.   4.  10.   7.   4.   7. ] 

starting from n=1, and these are supposed to be $x(n)$ values for each year (n). But in the solution, there aren't any parameters to play with for any kind of fitting procedure. Maybe the solution was wrong to begin with. Any ideas?

Addition:

Based on r.e.s.'s answer, I coded this

patents = np.array([  4.,   3.,   2.,   8.,   4.,                         4.,  10.,   4.,  10.,   7.])  def u(n,k):     if n-k < 0: return 0     return 1.  def y(n,data):     sum = 0     for k in range(len(data)):         sum += data[k]*(0.85**(n-k))*u(n,k)     return sum  for n in range(len(patents)):         print  y(n,patents) 

and it gave the same results I received from Python's lfilter function.

Thanks,

Note: The difference equation above is known as "cumulative sum with deprecitation" in literature.

  • 0
    re your coding: I notice that MATLAB has some built-in functions that might be useful in this context (e.g. [conv](http://www.mathworks.com/help/techdoc/ref/conv.html) and [filter](http://www.mathworks.com/help/techdoc/ref/filter.html)). I'm not familiar with this software, however.2011-12-14
  • 0
    There seem to be a couple of data values omitted from your array.2011-12-14
  • 0
    yea i dropped few2011-12-14

1 Answers 1

0

What you're calling the "solution" $h$ of the difference equation is the impulse response function for the discrete input-output system described by that equation. (I.e., $h$ is the solution to that equation when the inputs are unit impulses, $x(n) = \delta_n$.) Because this is a linear time-invariant system, it is completely characterized by the function $h$, and the outputs $y(n)$ can be expressed in terms of the inputs $x(n)$ via the convolution:

$$y(n) = \sum_{k=-\infty}^\infty x(k) h(n-k) = \sum_{k=-\infty}^\infty x(k) 0.85^{n-k} u(n-k).$$

  • 0
    Is it by convention then in tables for inverse z Transform, they show impulse response function h, instead of the full blown y(n)? Because people know how to take that apply the convolution you showed above?2011-12-14
  • 0
    I don't know, but I would expect tables to list transform pairs, in which case it would most likely be the *transfer function* $H$ that's listed. Typically, z-transforms would be applied to the difference equation to obtain the transfer function $H(z) = Y(z)/X(z)$ (where $X(z)$ and $Y(z)$ are the z-transforms of $\{x(n)\}$ and $\{y(n)\}$, respectively), which can be shown to be equal to the z-transform of the impulse response function $h$; so, $h = \mathcal{Z}^{-1} H$, and the solution $y$ is then given by the convolution $y = h \star x$.2011-12-14
  • 1
    @user6786: In other words, yes: as you say, the pairs listed could be viewed as $h$ and $H$, with convolution giving the input-output relationship in terms of $h$.2011-12-14