The Gambler's Ruin Problem 賭徒破產

Example (The Gambler's Ruin)
Two gamblers, A and B, bet on the outcomes of successive flips of a coin. On each flip, if the coin comes up heads, A collects 1 unit from B, whereas, if it comes up tails, A pays 1 unit to B. They continue to de this until one of them runs out of money. If it is assumed that the successive flips of the coin are independent and each flip results in a head with probability p, what is the probability that A ends up with all the money if he starts with i units and B starts with N-i units?
Solution:
Let E denote the event that A ends up with all the money when he starts with i and B with N-i, and to make clear the dependence on the initial fortune of A, let Pi=P(E). We shall obtain an expression for P(E) by conditioning on the outcome of the first flip as follows: Let H denote the event that the first flip lands heads; then
Now, given that the first flip lands heads, the situation after the first bet is that A has i+1 units and B has N-(i+1). Since the successive flips are assumed to be independent with a common probability p of heads, it follows that, from that point on, A's probability of winning all the money is exactly the same as if the game were just starting with A having an initial fortune of i+1 and B having an initial fortune of N-(i+1). Therefore, P(E|H)=Pi+1 and similarly, P(E|Hc)=Pi-1
Hence, letting q=1-p, we obtain
By making use of the obvious boundary conditions P0=0 and PN=1, we shall now solve Equation (4.2). Since p+q=1, these equations are equivalent to
Hence, since P0=0, we obtain from Equation (4.3):
Adding the first i-1 of Equation (4.4) yields
Now, using the fact that PN=1, we obtain
and hence
Let Qi denote the probability that B winds up with all the money when A starts with i and B with N-i. Then, by symmetry with the situation described and on replacing p by q and i by N-i, we see that
Moreover, since is equivalent to , we have when ,
As this result also holds when , we see that Pi+Qi=1
In words this equation states that with probability 1 either A or B will wind up with all of the money; or, in other words, the probability that the game continues indefinitely with A's fortune always being between 1 and N-1 is zero. (The reader must be careful because, a priori, there are three possible outcomes of this gambling game, not two. Either A wins or B wins or it goes on forever with nobody winning. We have just shown that this last event has probability 0.)
As a numerical illustration of the above result, if A were to start with 5 units and B with 10, then the probability of A's winning would be if p were , whereas it would jump to
if p were .6.