Suppose you have a $100 and you are offered a chance to play a game involving a fair coin toss:
If you throw heads your wealth increases by 50%.
If you throw tails your wealth decreases by 40%.
Assume that there is no upper bound to your wealth, i.e., you play the game until you are bankrupt. Let's assume that bankruptcy is an absorbing state and it is reached when your wealth is less than a dollar.
How one might describe the dynamics of your wealth when you go from coin toss $n$ to $n+1$. Moreover, what is the probability that you have increased your wealth after $N$ tosses?
Now that I finally understand the problem, I have a suggestion for approximating a solution. Change the rules so that the game ends either when the player goes bankrupt or when he has played $N$ times. Now the chain is finite, with two absorbing states, and we can compute the time to absorption and the probability of absorption in each state by standard methods. Since we know that the number of steps to absorption in the second absorbing state is $N$, and we also know the probability of absorption in that state, we can easily compute the average time to absorption in the first state.
The transient states are of the form $(w,\ell)$ meaning $\ell$ losses and $w$ wins, where $w+\ell<N$. Not all possibilities appear, because $\left(\frac35\right)^5<\frac1{10}$ so any player who has lost $5$ times more than he has won has gone bankrupt.
My thought is to try it for various values of $N$, until it stops changing. The main programming challenge is constructing the transition matrix.
Thanks for this programming problem. It will help beguile my isolation today.
Suppose we make a cutoff of $M$ rolls. Let $X$ be the average number of rolls until the game ends, whether by bankruptcy or cutoff, let $B$ be the event of bankruptcy, and $C$ the event of cutoff. We have $$\begin{align} E(X)&=\Pr(B)E(X|B)+\Pr(C)E(X|C)\\ &=(1-\Pr(C))E(X|B)+\Pr(C)M \end{align}$$ My program uses standard method to compute $E(X)$ and $\Pr(C)$ and then uses the above equation to solve for $E(X|B)$ the average time to bankruptcy among those players who went broke.
Here are the outputs from some successive runs:
The first number is the cutoff value, the second is the average time to bankruptcy, and the third is the probability of bankruptcy. It's starting to level off, and it's also starting to take a few minutes to run. I'll try to run it overnight with large cutoffs, and let you know what happens tomorrow.
EDIT
Since I first posted this, I realized that there were a lot of superfluous states in my original script. For example, with $M=100$, a player who wins $54$ games and loses $46$ does not go bankrupt, so once a player wins $54$ games, we know he will not go broke. To compute the number of steps to absorption correctly, we just keep track of the number of games such players have played. When $M=100$, this reduced the number of transient states from $2488$ to $1453$. Of course, we could compute the average time to bankruptcy, by eliminating the cutoff state, and forcing players to go bankrupt, so that any player with $53$ wins would lose from then on. This would reduce the number of transient states, by another $46$, but it would not allow computation of the probability of bankruptcy, which is nice to know. The script below is the revised one.
Here's my script, if you want to check it, which I would appreciate.