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.
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).$$