I asked this question on MSE, but didn't get enough information. If it is a violation of some norms, let me know, I'll delete it.


I'm having problem solving this difference equation. Initially I thought it should be quite easy to solve using generating functions (e.g. like in Migdal(2010), Woodbury(1949) or Gani(2006), but have made no progress so far. 


The intuition behind it is that each iteration population either increases by 1 species (with probability $p(x)$ or stays the same w.p. $q(x)$, so $A(n,x)$ can be seen as the expected size of the population at iteration $n$. 


It seems pretty straightforward, but I couldn't move along. I know the solution involves Casoratian and finding some product $\Pi\_{x=1}^{m}p(x)$, but apart form that I couldn'd do much. 


Also, if it happens to be some well-known problem, please don't solve it for me, just point in the right direction 


[MSE link](https://math.stackexchange.com/questions/78473/recurrence-an-x-pxan-1-x-1qxan-1-x)



Difference equation $A(n,x)=p(x)A(n-1,x-1)+q(x)A(n-1,x)$
Let 
$$P\_m(x,z) = \prod\_{k=0}^{m-1} (p(x-k)+q(x-k)z)$$
and
$$\mathcal{A\_n}(x,z) = \sum\_{k=0}^{\infty} A(n,x-k) z^k.$$


Then unrolling the given recurrence $m$ times, we get that $A(n,x)$ equals the coefficient of $z^m$ in
$$P\_m(x,z)\cdot \mathcal{A}\_{n-m}(x,z).$$
In particular, for $A(n,x)$ equals the coefficient of $z^n$ in
$$P\_n(x,z)\cdot \mathcal{A}\_{0}(x,z).$$


More could be said if the boundary constraints were given.


