# How to apply the solution of $y(n) = (0.85)y(n-1) + x(n)$ to data

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?

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.

-
re your coding: I notice that MATLAB has some built-in functions that might be useful in this context (e.g. conv and filter). I'm not familiar with this software, however. – r.e.s. Dec 14 '11 at 17:23
There seem to be a couple of data values omitted from your array. – r.e.s. Dec 14 '11 at 17:27
yea i dropped few – BB_ML Dec 14 '11 at 19:30

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).$$
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$. – r.e.s. Dec 14 '11 at 16:53
@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$. – r.e.s. Dec 14 '11 at 17:10