How to find number of poles from the unit sample response?
It would help to break down the difference equation:

$$y_n=\frac{1}{b_0}(a_0 x_n+a_1 x_{n-1}+a_2 x_{n-2}-b_1 y_{n-1}-b_2 y_{n-2})$$

Assume a monic polynomial, so b0=1, you can multiply afterwards if needed. At this point, think of what would it take you to write down this equation in a programming language. You would have to break it down into time pieces.


n=0. Since the input is the \$\delta_n\$ function, it's a 1 at n=0 and zero in rest, so:


$$y_n=a_0 x_n \Rightarrow a_0=...$$


n=1. a0 has been found out, xn-1 is zero, yn-1 is known:


$$y_n=a_0 x_n +( a_1 x_{n-1} - b_1 y_{n-1}) \Rightarrow b_1=...$$


n=2. Again, some are known, some can be simplified thanks to the \$\delta_n\$ input, and given the equation you find out the missing terms, one by one.


Eventually, you'll find that the answer cannot have more terms and the equation found out at this point can be used to verify the rest of the impulse. This is not really done in practise, but it helps to understand that there is a way to systematically determine the transfer function, when they're not so complicated.