Suppose a tank has a maximum limit of 100 units. Each day 2,1 and 0 units are added to the water level with probability p,r and q. Any excess water would overflow and if it reaches the minimum level of 0 then it cannot be filled again.At the end of the day 1 unit is released from the tank. I tried to solve this the following way.
Let L be the random variable corresponding to the water level at the end of the day. $$Pr[L=k+1]=p, Pr[L=k]=r,Pr[L=k-1]=q$$ Let $q_k$ be the probability that the water level will become 0 if, at the beginning of the day the water level is k. Then, $$q_k=pq_{k+1}+rq_k+qq_{k-1}$$
Solving this by difference equations I got the following general solution $$q_k=A+B(q/p)^k$$
To determine A and B I need suitable boundary conditions. Should I use $q_{99}=0$ or $q_{100}=0$? I think the tank can never be at 100 water level at end of any day so $q_{99}=0$?
Also the recurrence formula I have written for $q_k$, should it be for k values between 1 and 99 or 1 and 98? ANy help will be much appreciated.