Emrah Mete simulates a random walk in R:
Let’s consider a game where a gambler is likely to win $1 with a probability of p and lose $1 with a probability of 1-p.
Now, let’s consider a game where a gambler is likely to win $1 and lose $1 with a probability of 1. The player starts the game with X dollars in hand. The player plays the game until the money in his hand reaches N (N> X) or he has no money left. What is the probability that the player will reach the target value? (We know that the player will not leave the game until he reaches the N value he wants to win.)
The problem of the story above is known in literature as Gambler’s Ruin or Random Walk. In this article, I will simulate this problem with R with different settings and examine how the game results change with different settings.
Click through for the script and analysis. There’s a reason they call this game the gambler’s ruin.