Catalog/gt-gamblers-ruin

Game Theory

Gambler's ruin API

Computes the probability of reaching a target before going broke and the expected number of bets in the classic random-walk gambler's ruin, handling fair and biased games. Answers 'What is my chance of doubling my bankroll before ruin?', 'How long until the random walk hits a boundary?'.

Price$0.06per request
MethodPOST
Route/v1/gametheory/gamblers-ruin
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
probabilitygamblers-ruinrandom-walkmarkovbettingruinstoppingdecision
API URLhttps://x402.hexl.dev/v1/gametheory/gamblers-ruin
Integration docs
Example request
{
  "startingCapital": 5,
  "targetCapital": 10,
  "winProbability": 0.45
}
Example response
{
  "startingCapital": 5,
  "targetCapital": 10,
  "winProbability": 0.45,
  "probReachTarget": 0.2682825988,
  "probRuin": 0.7317174012,
  "expectedDuration": 23.17174,
  "fair": false,
  "interpretation": "Starting with 5 aiming for 10 at per-bet win prob 0.45: probability of reaching the target is 26.8283%, expected 23.2 bets before stopping."
}
Input schema
{
  "type": "object",
  "required": [
    "startingCapital",
    "targetCapital",
    "winProbability"
  ],
  "properties": {
    "startingCapital": {
      "type": "integer",
      "minimum": 0,
      "examples": [
        5
      ]
    },
    "targetCapital": {
      "type": "integer",
      "minimum": 1,
      "examples": [
        10
      ]
    },
    "winProbability": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "examples": [
        0.45
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}