{
  "id": "gamblers-ruin",
  "title": "Gambler's Ruin",
  "lang": "en",
  "source_lang": "en",
  "summary": "Gambler’s ruin studies the probability and timing of bankruptcy for a player whose capital changes through repeated random gains and losses.",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "Gambler’s ruin problem",
    "Classical ruin problem"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/gamblers-ruin/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/gamblers-ruin/",
      "json": "https://aiwiki.page/zh/gamblers-ruin.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "Gambler’s ruin is a classical problem in probability theory concerning a player who repeatedly wins or loses a fixed amount until either becoming bankrupt or reaching a prescribed capital target. In its standard form, the player’s capital follows a random walk between two absorbing boundaries. The problem asks for the probability of reaching each boundary and the time required to do so. It illustrates an important distinction: a game can have zero expected gain on each play while still leading a player with finite capital to eventual bankruptcy when play continues without an upper stopping target."
    },
    {
      "heading": "Classical model",
      "text": "Suppose a player begins with an integer capital \\(i\\), where \\(0<i<N\\). On each play:\n\n- capital increases by one unit with probability \\(p\\);\n- capital decreases by one unit with probability \\(q=1-p\\);\n- successive outcomes are independent, with the same probabilities on every play.\n\nAssume \\(0<p<1\\). Write \\(X_n\\) for the player’s capital after \\(n\\) plays, with \\(X_0=i\\). Play stops when capital reaches either \\(0\\), representing ruin, or \\(N\\), representing success.\n\nThe stopping time is\n\n\\[T=\\inf\\{n\\geq 0:X_n\\in\\{0,N\\}\\}.\\]\n\nAfter stopping, the process may be defined to remain at the boundary it has reached. It is then a finite Markov chain with absorbing states \\(0\\) and \\(N\\).\n\nAn equivalent interpretation involves two players whose combined capital is \\(N\\). Each play transfers one unit from one player to the other, and the game ends when one player holds all the capital.\n\nThe model distinguishes two questions:\n\n- Ruin probability: What is the probability of reaching \\(0\\) before \\(N\\)?\n- Duration: How many plays occur before either boundary is reached?\n\nA favorable answer to one question need not imply a favorable answer to the other."
    },
    {
      "heading": "Probability of reaching the target",
      "text": "Let\n\n\\[u_i=\\Pr(X_T=N\\mid X_0=i)\\]\n\nbe the probability of reaching the target before ruin. Conditioning on the first play gives the recurrence relation\n\n\\[u_i=pu_{i+1}+qu_{i-1}, \\qquad 1\\leq i\\leq N-1,\\]\n\nwith boundary conditions\n\n\\[u_0=0,\\qquad u_N=1.\\]\n\nThis is a discrete boundary-value problem. Its solution is\n\n\\[u_i= \\begin{cases} \\displaystyle \\frac{1-(q/p)^i}{1-(q/p)^N}, & p\\neq q,\\\\[1.2em] \\displaystyle \\frac{i}{N}, & p=q=\\frac12. \\end{cases}\\]\n\nThe ruin probability \\(r_i=1-u_i\\) is therefore\n\n\\[r_i= \\begin{cases} \\displaystyle \\frac{(q/p)^i-(q/p)^N}{1-(q/p)^N}, & p\\neq q,\\\\[1.2em] \\displaystyle 1-\\frac{i}{N}, & p=q=\\frac12. \\end{cases}\\]\n\nDerivation\n\nWhen \\(p\\neq q\\), rearranging the recurrence gives\n\n\\[p(u_{i+1}-u_i)=q(u_i-u_{i-1}).\\]\n\nThus successive differences form a geometric progression with ratio \\(q/p\\). Summing those differences and imposing the boundary conditions yields the stated formula.\n\nWhen \\(p=q\\), the recurrence becomes\n\n\\[u_{i+1}-2u_i+u_{i-1}=0.\\]\n\nIts solutions are linear in \\(i\\), and the boundary values give \\(u_i=i/N\\). In the language of discrete potential theory, \\(u_i\\) is a harmonic function for the transition rule.\n\nInterpretation\n\nFor a fair game, the probability of success equals the fraction of the total capital initially held. A player starting with \\(20\\) units and aiming for \\(100\\) has probability\n\n\\[u_{20}=\\frac{20}{100}=0.2\\]\n\nof reaching the target and probability \\(0.8\\) of ruin.\n\nFor an unfavorable game, \\(p<q\\), raising the target while keeping initial capital fixed makes success increasingly unlikely. For a favorable game, \\(p>q\\), increasing initial capital reduces ruin risk, but the risk remains positive for every finite initial capital."
    },
    {
      "heading": "Expected duration",
      "text": "Let\n\n\\[m_i=\\mathbb{E}[T\\mid X_0=i]\\]\n\ndenote the expected number of plays before absorption. First-step conditioning gives\n\n\\[m_i=1+pm_{i+1}+qm_{i-1}, \\qquad m_0=m_N=0.\\]\n\nThe solution is\n\n\\[m_i= \\begin{cases} \\displaystyle \\frac{i-Nu_i}{q-p}, & p\\neq q,\\\\[1.2em] i(N-i), & p=q=\\frac12. \\end{cases}\\]\n\nFor the fair-game example with \\(i=20\\) and \\(N=100\\),\n\n\\[m_{20}=20(100-20)=1600.\\]\n\nThis is an average over games ending at either boundary, not the expected duration conditional on success or conditional on ruin.\n\nIn the fair case, duration is largest when initial capital is closest to \\(N/2\\). If \\(i\\) remains a fixed fraction of \\(N\\), expected duration grows proportionally to \\(N^2\\).\n\nFor every fixed finite \\(N\\), absorption occurs almost surely and has finite expected duration. One way to see this is that, from any interior state, a run of at most \\(N\\) consecutive losses produces ruin. The probability of such a run provides a positive lower bound on absorption within each block of \\(N\\) plays, producing a geometric bound on the tail of \\(T\\)."
    },
    {
      "heading": "No upper capital limit",
      "text": "A different version removes the upper boundary. The player starts with \\(i>0\\) and continues until reaching zero, if that ever happens. Let\n\n\\[\\tau_0=\\inf\\{n\\geq0:X_n=0\\}.\\]\n\nTaking the upper target \\(N\\) to infinity in the finite-boundary ruin probability gives\n\n\\[\\Pr_i(\\tau_0<\\infty)= \\begin{cases} 1, & p\\leq q,\\\\[0.6em] \\displaystyle \\left(\\frac qp\\right)^i, & p>q. \\end{cases}\\]\n\nThe cases have different interpretations:\n\n- Unfavorable game, \\(p<q\\): ruin occurs almost surely.\n- Fair game, \\(p=q\\): ruin also occurs almost surely, despite zero expected gain on each play.\n- Favorable game, \\(p>q\\): there is a positive probability of avoiding ruin forever.\n\nThe expected ruin time further distinguishes the cases. If \\(p<q\\),\n\n\\[\\mathbb{E}_i[\\tau_0]=\\frac{i}{q-p}.\\]\n\nFor the fair game,\n\n\\[\\Pr_i(\\tau_0<\\infty)=1, \\qquad \\mathbb{E}_i[\\tau_0]=\\infty.\\]\n\nThus a random variable can be finite with probability one while having infinite expectation. Rare, extremely long games make the average ruin time diverge.\n\nWhen \\(p>q\\), the unconditional expectation of \\(\\tau_0\\), interpreted as an extended nonnegative random variable, is also infinite because \\(\\tau_0=\\infty\\) with positive probability. This is distinct from the expected duration conditional on eventual ruin.\n\n“Certain eventual ruin” in the fair or unfavorable model does not mean ruin must occur within some fixed number of plays. Every finite deadline still leaves a positive probability of survival."
    },
    {
      "heading": "Martingales and stopping",
      "text": "The ruin formulas are central examples in martingale theory. A martingale has the property that its conditional expected future value, given present information, equals its current value.\n\nIn the fair game, capital \\(X_n\\) is a martingale before absorption. For the finite-boundary model, the optional stopping theorem justifies\n\n\\[\\mathbb{E}_i[X_T]=i.\\]\n\nBecause \\(X_T\\) is either \\(0\\) or \\(N\\),\n\n\\[Nu_i=i,\\]\n\nwhich immediately yields \\(u_i=i/N\\).\n\nFor \\(p\\neq q\\), the exponential process\n\n\\[\\left(\\frac qp\\right)^{X_n}\\]\n\nis a martingale before absorption, since\n\n\\[p\\left(\\frac qp\\right) + q\\left(\\frac pq\\right)=1.\\]\n\nApplying optional stopping to the bounded, stopped process gives\n\n\\[\\left(\\frac qp\\right)^i = (1-u_i)+u_i\\left(\\frac qp\\right)^N,\\]\n\nwhich yields the biased-game formula.\n\nIn a fair game, \\(X_n^2-n\\) is also a martingale before absorption and can be used to derive the expected duration.\n\nWhy stopping assumptions matter\n\nFor the fair game without an upper boundary, ruin occurs almost surely and terminal capital is zero. Nevertheless, it is invalid to conclude from the martingale property alone that expected terminal capital must equal initial capital.\n\nFor each fixed \\(n\\),\n\n\\[\\mathbb{E}_i[X_{n\\wedge\\tau_0}]=i,\\]\n\nwhile\n\n\\[X_{n\\wedge\\tau_0}\\longrightarrow 0 \\quad\\text{almost surely}.\\]\n\nExpectations cannot generally be interchanged with limits without additional conditions. In this example, increasingly rare surviving paths can carry increasingly large capital. The stopped variables are not uniformly integrable, and the mean ruin time is infinite."
    },
    {
      "heading": "Extensions and applications",
      "text": "Unequal stakes and variable transition probabilities\n\nThe classical formulas depend on unit-sized gains and losses and constant \\(p\\). If capital changes by larger amounts, boundaries may be crossed rather than hit exactly, producing an overshoot. Boundary conditions must then account for all exit states.\n\nIf the win probability depends on current capital, the success probabilities instead satisfy\n\n\\[u_i=p_i u_{i+1}+(1-p_i)u_{i-1}.\\]\n\nSuch models retain the first-step approach but no longer generally have the simple constant-bias formula.\n\nAbsorption-time distributions\n\nExpected duration does not describe the full distribution of the game’s length. Let \\(Q\\) be the portion of the transition matrix corresponding to the transient states \\(1,\\ldots,N-1\\). Then\n\n\\[\\Pr_i(T>n)=e_i^{\\mathsf T}Q^n\\mathbf{1},\\]\n\nwhere \\(e_i\\) selects the initial state and \\(\\mathbf{1}\\) is the vector of ones.\n\nThe matrix\n\n\\[F=(I-Q)^{-1}\\]\n\nis the fundamental matrix of the absorbing chain. Its entry \\(F_{ij}\\) gives the expected number of visits to transient state \\(j\\) before absorption, starting from \\(i\\). Summing row \\(i\\) gives \\(m_i\\).\n\nDiffusion approximation\n\nWith suitable rescaling of time and capital, random walks lead to continuous models based on the Wiener process. For a diffusion with constant drift \\(\\mu\\) and variance rate \\(\\sigma^2\\), the probability \\(u(x)\\) of reaching an upper boundary \\(L\\) before zero satisfies\n\n\\[\\mu u'(x)+\\frac{\\sigma^2}{2}u''(x)=0, \\qquad u(0)=0,\\quad u(L)=1.\\]\n\nIts solution is\n\n\\[u(x)= \\begin{cases} \\displaystyle \\frac{1-e^{-2\\mu x/\\sigma^2}} {1-e^{-2\\mu L/\\sigma^2}}, & \\mu\\neq0,\\\\[1.2em] \\displaystyle \\frac{x}{L}, & \\mu=0. \\end{cases}\\]\n\nThese continuous formulas parallel the discrete ruin probabilities.\n\nCapital reserves and other finite populations\n\nRuin models provide simplified descriptions of capital reserves depleted by random losses. Related boundary-hitting problems arise in queues, inventory systems, and population models. In insurance mathematics, reserve processes typically include premium income and claims of varying sizes, so the elementary gambler’s ruin formula is a prototype rather than a direct description.\n\nIn simple neutral population models, the number of individuals carrying a variant can move between extinction and fixation. When changes are symmetric, the fixation probability has the same linear form as the fair gambler’s success probability."
    },
    {
      "heading": "Limitations and common misconceptions",
      "text": "The classical result assumes fixed stakes, independent outcomes, constant win probabilities, and no borrowing or replenishment of capital. Dependence between outcomes, changing stakes, transaction costs, or external income changes the process and may change both ruin probabilities and durations.\n\nA positive expected gain per play does not eliminate bankruptcy risk. With \\(p>q\\), the player has a favorable drift, yet an early sequence of losses can still exhaust finite capital.\n\nConversely, almost-sure ruin in the fair unlimited-horizon model does not imply that the game has a negative expected gain per play. Fairness concerns expected increments; ruin concerns an entire random path and its boundary behavior.\n\nThe problem is also distinct from the gambler’s fallacy: under the independence assumption, a sequence of losses does not make a win more likely on the next play. Finally, the formulas for fixed unit stakes cannot simply be applied to betting systems that change the stake after wins or losses; those systems require a different model."
    }
  ],
  "links": [
    "probability",
    "random-walk",
    "statistical-independence",
    "markov-chain",
    "recurrence-relation",
    "boundary-value-problem",
    "geometric-series",
    "harmonic-function",
    "expected-value",
    "almost-surely",
    "random-variable",
    "martingale",
    "conditional-expectation",
    "probability-distribution",
    "transition-matrix",
    "wiener-process"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}