# How do I find the difference equation from a transfer function?

Most of the resources I found online go the other way. If I have the transfer function $H(z) = 1 - cos(\theta) \cdot z^{-1} + z^{-2}$ how do I get the difference equation from it so that I can apply the transfer function to a set of data?

A transfer function $H(Z)$ can be written as $H(Z)=\frac{Y(Z)}{X(Z)}$. Then, your $H(Z)$ can be written as
$\frac{Y(Z)}{X(Z)}=1-\cos\theta~Z^{-1}+Z^{-2}$ or
$Y(Z)=X(Z)(1-\cos\theta~ Z^{-1}+Z^{-2})$
Now taking the inverse $Z$transform, we get the difference equation as
$y(n)=x(n)-\cos\theta~x(n-1)+x(n-2)$.