Skip to main content
aifinhub

Worked example

Running the shipped drawdown-recovery-markov engine on the input below produces exactly this output. Continuous integration recomputes it against the engine bundle on every build, so these numbers cannot drift from the code.

Input

{
  "tool": "drawdown-recovery-markov",
  "monthly_sharpe": 0.6,
  "monthly_skew": -0.3,
  "monthly_excess_kurt": 2,
  "recovery_threshold": 0.2,
  "paths": 2000,
  "max_months": 120,
  "seed": 42
}

Output2010 lines

{
  "median": 10,
  "p25": 7,
  "p75": 13,
  "p95": 21,
  "pctRecoveredIn12Mo": 0.693,
  "pctNeverRecovered": 0,
  "recoveryTimes": [
    4,
    5,
    6,
    17,
    11,
    13,
    10,
    12,
    17,
    13,
    6,
    9,
    10,
    8,
    8,
    16,
    6,
    8,
    15,
    8,
    5,
    6,
    9,
    8,
    14,
    21,
    4,
    8,
    12,
    18,
    36,
    6,
    6,
    7,
    9,
    17,
    3,
    4,
    6,
    18,
    7,
    18,
    25,
    10,
    13,
    8,
    14,
    9,
    6,
    5,
    17,
    14,
    19,
    10,
    9,
    8,
    7,
    11,
    9,
    10,
    6,
    16,
    6,
    16,
    16,
    12,
    8,
    11,
    6,
    3,
    16,
    6,
    17,
    11,
    7,
    12,
    8,
    14,
    13,
    7,
    11,
    13,
    21,
    14,
    6,
    6,
    11,
    11,
    8,
    14,
    10,
    4,
    11,
    10,
    6,
    5,
    16,
    19,
    11,
    4,
    14,
    5,
    11,
    10,
    7,
    7,
    10,
    8,
    9,
    6,
    12,
    8,
    15,
    14,
    13,
    9,
    17,
    11,
    7,
    15,
    7,
    5,
    2,
    6,
    15,
    12,
    4,
    21,
    26,
    6,
    5,
    12,
    9,
    11,
    9,
    5,
    17,
    11,
    19,
    16,
    9,
    10,
    5,
    10,
    7,
    19,
    13,
    9,
    13,
    16,
    7,
    12,
    9,
    5,
    11,
    5,
    9,
    11,
    8,
    15,
    16,
    6,
    11,
    10,
    12,
    6,
    10,
    9,
    6,
    6,
    13,
    4,
    5,
    4,
    9,
    6,
    21,
    10,
    19,
    7,
    6,
    10,
    5,
    8,
    12,
    7,
    14,
    15,
    13,
    6,
    7,
    12,
    18,
    8,
    21,
    17,
    4,
    19,
    22,
    13,
    5,
    9,
    11,
    25,
    14,
    9,
    14,
    13,
    3,
    19,
    12,
    9,
    13,
    7,
    10,
    15,
    4,
    8,
    7,
    19,
    28,
    8,
    10,
    7,
    7,
    6,
    10,
    20,
    5,
    25,
    18,
    11,
    6,
    10,
    5,
    14,
    5,
    4,
    15,
    5,
    11,
    10,
    6,
    11,
    7,
    9,
    11,
    7,
    15,
    10,
    15,
    14,
    13,
    10,
    8,
    14,
    7,
    6,
    9,
    9,
    6,
    10,
    12,
    8,
    8,
    6,
    9,
    11,
    13,
    9,
    11,
    28,
    5,
    21,
    12,
    10,
    6,
    16,
    12,
    17,
    18,
    26,
    6,
    11,
    7,
    14,
    6,
    12,
    10,
    10,
    13,
    18,
    13,
    7,
    4,
    11,
    15,
    8,
    9,
    15,
    7,
    5,
    8,
    27,
    13,
    7,
    9,
    9,
    13,
    10,
    12,
    16,
    12,
    10,
    8,
    5,
    16,
    5,
    9,
    11,
    6,
    8,
    8,
    10,
    15,
    7,
    11,
    14,
    7,
    7,
    8,
    7,
    7,
    11,
    5,
    8,
    6,
    10,
    6,
    6,
    7,
    10,
    15,
    12,
    13,
    18,
    6,
    17,
    21,
    10,
    9,
    9,
    15,
    7,
    7,
    6,
    17,
    12,
    7,
    11,
    5,
    11,
    10,
    7,
    5,
    8,
    3,
    8,
    19,
    13,
    14,
    9,
    7,
    5,
    10,
    13,
    14,
    31,
    5,
    10,
    12,
    19,
    7,
    10,
    16,
    11,
    11,
    5,
    9,
    3,
    15,
    10,
    11,
    4,
    10,
    17,
    6,
    13,
    10,
    6,
    8,
    6,
    8,
    4,
    9,
    11,
    15,
    5,
    6,
    6,
    7,
    6,
    11,
    7,
    12,
    6,
    20,
    6,
    12,
    6,
    7,
    2,
    9,
    14,
    11,
    15,
    13,
    10,
    25,
    10,
    3,
    4,
    23,
    6,
    16,
    24,
    6,
    5,
    10,
    22,
    7,
    12,
    8,
    11,
    7,
    14,
    9,
    10,
    10,
    15,
    17,
    6,
    8,
    6,
    7,
    30,
    13,
    12,
    23,
    10,
    3,
    16,
    13,
    15,
    5,
    10,
    9,
    7,
    8,
    11,
    4,
    7,
    8,
    10,
    11,
    13,
    19,
    12,
    5,
    13,
    22,
    5,
    24,
    9,
    20,
    11,
    8,
    8,
    11,
    14,
    20,
    18,
    17,
    3,
    7,
    9,
    14,
    22,
    9,
    16,
    14,
    6,
    8,
    13,
    15,
    17,
    10,
    6,
    10,
    4,
    13,
    11,
    9,
    5,
    10,
    6,
    11,
    6,
    5,
    7,
    4,
    12,
    6,
    11,
    11,
    6,
    15,
    10,
    12,
    13,
    11,
    9,
    9,
    9,
    4,
    7,
    8,
    5,
    8,
    14,
    13,
    13,
    17,
    6,
    21,
    6,
    10,
    10,
    8,
    15,
    5,
    13,
    10,
    8,
    20,
    10,
    10,
    5,
    10,
    12,
    7,
    3,
    17,
    11,
    21,
    14,
    13,
    9,
    31,
    8,
    5,
    20,
    8,
    6,
    18,
    10,
    11,
    4,
    6,
    22,
    19,
    4,
    14,
    29,
    7,
    19,
    8,
    8,
    6,
    6,
    5,
    5,
    6,
    6,
    7,
    5,
    11,
    10,
    7,
    9,
    3,
    7,
    7,
    20,
    5,
    16,
    7,
    5,
    8,
    14,
    7,
    12,
    12,
    6,
    8,
    13,
    4,
    11,
    12,
    13,
    11,
    10,
    5,
    5,
    8,
    7,
    10,
    12,
    10,
    17,
    10,
    16,
    8,
    5,
    12,
    7,
    18,
    14,
    5,
    5,
    8,
    9,
    23,
    15,
    12,
    13,
    12,
    13,
    9,
    6,
    13,
    9,
    13,
    16,
    13,
    11,
    5,
    14,
    11,
    12,
    15,
    8,
    5,
    6,
    17,
    19,
    8,
    6,
    10,
    4,
    6,
    7,
    15,
    22,
    12,
    12,
    17,
    10,
    16,
    18,
    12,
    16,
    49,
    34,
    8,
    12,
    16,
    12,
    12,
    10,
    6,
    11,
    10,
    7,
    5,
    6,
    7,
    11,
    5,
    12,
    7,
    11,
    7,
    15,
    12,
    10,
    12,
    24,
    18,
    8,
    10,
    9,
    22,
    18,
    18,
    12,
    14,
    5,
    11,
    5,
    6,
    14,
    9,
    6,
    6,
    7,
    7,
    6,
    11,
    9,
    5,
    9,
    6,
    6,
    45,
    11,
    10,
    20,
    14,
    19,
    23,
    14,
    18,
    12,
    12,
    14,
    11,
    14,
    8,
    9,
    18,
    10,
    11,
    16,
    10,
    5,
    9,
    6,
    6,
    12,
    6,
    18,
    19,
    8,
    10,
    12,
    25,
    7,
    11,
    8,
    10,
    5,
    8,
    11,
    10,
    10,
    15,
    8,
    31,
    7,
    9,
    11,
    17,
    6,
    5,
    12,
    21,
    6,
    10,
    12,
    4,
    10,
    7,
    4,
    5,
    14,
    15,
    6,
    21,
    8,
    10,
    5,
    8,
    7,
    8,
    6,
    3,
    8,
    13,
    7,
    8,
    13,
    12,
    7,
    20,
    8,
    13,
    15,
    14,
    8,
    7,
    7,
    13,
    12,
    5,
    8,
    12,
    18,
    10,
    6,
    14,
    9,
    37,
    10,
    12,
    21,
    6,
    4,
    5,
    13,
    8,
    7,
    14,
    20,
    8,
    6,
    10,
    5,
    9,
    6,
    5,
    8,
    6,
    15,
    13,
    5,
    10,
    8,
    13,
    7,
    16,
    5,
    7,
    9,
    8,
    8,
    11,
    11,
    14,
    12,
    11,
    22,
    12,
    29,
    8,
    9,
    10,
    6,
    5,
    13,
    7,
    11,
    12,
    7,
    16,
    22,
    15,
    8,
    18,
    9,
    19,
    21,
    9,
    11,
    14,
    10,
    14,
    18,
    26,
    12,
    10,
    5,
    8,
    5,
    13,
    8,
    8,
    2,
    19,
    19,
    20,
    15,
    6,
    5,
    7,
    15,
    29,
    18,
    4,
    3,
    9,
    9,
    6,
    9,
    10,
    3,
    6,
    6,
    24,
    11,
    11,
    14,
    36,
    9,
    11,
    15,
    4,
    8,
    23,
    9,
    7,
    12,
    8,
    10,
    9,
    9,
    10,
    6,
    5,
    17,
    9,
    14,
    10,
    15,
    11,
    12,
    7,
    12,
    6,
    13,
    13,
    13,
    17,
    8,
    8,
    6,
    27,
    6,
    9,
    11,
    9,
    3,
    8,
    8,
    7,
    10,
    13,
    3,
    16,
    8,
    8,
    12,
    10,
    9,
    18,
    8,
    14,
    8,
    6,
    5,
    8,
    6,
    4,
    5,
    9,
    10,
    7,
    9,
    10,
    10,
    8,
    18,
    6,
    9,
    5,
    5,
    7,
    7,
    10,
    9,
    6,
    15,
    13,
    15,
    6,
    7,
    16,
    12,
    7,
    12,
    12,
    7,
    13,
    11,
    6,
    14,
    11,
    8,
    10,
    7,
    7,
    12,
    10,
    11,
    12,
    8,
    5,
    18,
    8,
    9,
    8,
    6,
    9,
    7,
    8,
    26,
    12,
    7,
    9,
    8,
    7,
    8,
    25,
    9,
    6,
    21,
    11,
    6,
    6,
    9,
    7,
    3,
    7,
    16,
    5,
    8,
    10,
    15,
    8,
    8,
    10,
    8,
    8,
    9,
    14,
    17,
    17,
    20,
    5,
    6,
    7,
    16,
    9,
    9,
    16,
    16,
    8,
    11,
    13,
    9,
    10,
    7,
    18,
    15,
    14,
    11,
    5,
    16,
    15,
    13,
    8,
    10,
    8,
    18,
    9,
    26,
    10,
    7,
    20,
    13,
    7,
    4,
    10,
    26,
    9,
    8,
    10,
    8,
    8,
    13,
    20,
    13,
    10,
    13,
    7,
    5,
    28,
    16,
    6,
    8,
    8,
    5,
    13,
    17,
    23,
    6,
    25,
    17,
    7,
    7,
    7,
    8,
    16,
    2,
    8,
    6,
    7,
    17,
    9,
    24,
    11,
    8,
    8,
    12,
    11,
    9,
    16,
    19,
    5,
    8,
    10,
    15,
    10,
    6,
    8,
    8,
    5,
    11,
    10,
    19,
    4,
    9,
    17,
    9,
    9,
    13,
    4,
    18,
    16,
    6,
    10,
    6,
    6,
    11,
    12,
    18,
    14,
    13,
    10,
    4,
    17,
    8,
    28,
    10,
    6,
    13,
    5,
    25,
    17,
    20,
    14,
    7,
    11,
    13,
    5,
    16,
    12,
    14,
    8,
    9,
    17,
    7,
    13,
    35,
    11,
    11,
    13,
    6,
    8,
    18,
    33,
    8,
    27,
    12,
    6,
    22,
    7,
    7,
    12,
    7,
    13,
    9,
    10,
    22,
    6,
    23,
    7,
    7,
    14,
    7,
    7,
    17,
    9,
    11,
    17,
    11,
    14,
    14,
    11,
    15,
    13,
    12,
    8,
    8,
    11,
    23,
    12,
    7,
    8,
    17,
    11,
    5,
    12,
    8,
    10,
    9,
    10,
    4,
    11,
    9,
    10,
    6,
    13,
    5,
    11,
    9,
    6,
    14,
    21,
    10,
    14,
    7,
    11,
    13,
    15,
    17,
    8,
    11,
    17,
    8,
    9,
    18,
    13,
    9,
    15,
    9,
    12,
    9,
    15,
    6,
    13,
    9,
    7,
    9,
    12,
    17,
    20,
    9,
    29,
    13,
    13,
    18,
    11,
    16,
    6,
    8,
    7,
    7,
    8,
    12,
    6,
    17,
    4,
    12,
    14,
    8,
    8,
    10,
    8,
    6,
    14,
    7,
    5,
    9,
    11,
    6,
    9,
    10,
    21,
    9,
    14,
    11,
    12,
    8,
    15,
    13,
    11,
    7,
    5,
    7,
    11,
    10,
    9,
    8,
    8,
    8,
    9,
    9,
    4,
    29,
    7,
    8,
    13,
    10,
    6,
    17,
    13,
    10,
    19,
    14,
    6,
    7,
    14,
    15,
    33,
    10,
    13,
    7,
    8,
    15,
    10,
    12,
    12,
    4,
    14,
    6,
    9,
    15,
    3,
    11,
    15,
    24,
    8,
    16,
    5,
    11,
    11,
    8,
    5,
    13,
    5,
    17,
    7,
    11,
    6,
    8,
    13,
    24,
    18,
    23,
    14,
    9,
    8,
    8,
    9,
    5,
    8,
    7,
    9,
    7,
    12,
    11,
    7,
    11,
    4,
    6,
    7,
    7,
    6,
    18,
    8,
    6,
    8,
    15,
    15,
    5,
    15,
    18,
    10,
    22,
    11,
    7,
    3,
    12,
    9,
    8,
    4,
    9,
    10,
    10,
    10,
    9,
    13,
    12,
    5,
    20,
    15,
    30,
    15,
    9,
    6,
    14,
    7,
    6,
    7,
    3,
    7,
    8,
    11,
    10,
    9,
    16,
    10,
    8,
    14,
    5,
    8,
    7,
    7,
    2,
    4,
    7,
    10,
    9,
    6,
    6,
    9,
    16,
    5,
    6,
    7,
    9,
    17,
    29,
    5,
    14,
    7,
    5,
    9,
    13,
    6,
    18,
    8,
    5,
    13,
    9,
    10,
    15,
    22,
    10,
    14,
    5,
    10,
    12,
    8,
    14,
    6,
    15,
    30,
    11,
    4,
    10,
    6,
    11,
    6,
    8,
    31,
    8,
    22,
    34,
    12,
    6,
    7,
    9,
    23,
    8,
    10,
    4,
    15,
    9,
    4,
    27,
    15,
    14,
    11,
    12,
    13,
    17,
    15,
    12,
    13,
    15,
    4,
    36,
    8,
    3,
    3,
    7,
    16,
    6,
    7,
    13,
    6,
    4,
    14,
    8,
    12,
    14,
    17,
    6,
    7,
    6,
    14,
    11,
    18,
    7,
    17,
    8,
    12,
    5,
    13,
    19,
    7,
    9,
    17,
    4,
    23,
    19,
    11,
    16,
    6,
    11,
    25,
    5,
    7,
    10,
    13,
    16,
    10,
    14,
    17,
    9,
    16,
    9,
    14,
    15,
    27,
    5,
    5,
    15,
    21,
    6,
    24,
    10,
    9,
    10,
    9,
    13,
    7,
    12,
    6,
    16,
    6,
    7,
    8,
    9,
    9,
    6,
    9,
    14,
    7,
    15,
    6,
    17,
    10,
    10,
    12,
    7,
    8,
    12,
    9,
    13,
    12,
    14,
    7,
    12,
    11,
    15,
    8,
    13,
    6,
    8,
    9,
    12,
    6,
    7,
    4,
    23,
    20,
    18,
    11,
    16,
    15,
    14,
    10,
    10,
    10,
    10,
    13,
    14,
    5,
    5,
    11,
    8,
    14,
    8,
    15,
    5,
    8,
    8,
    6,
    14,
    6,
    6,
    10,
    11,
    12,
    13,
    24,
    14,
    15,
    8,
    7,
    10,
    7,
    6,
    24,
    31,
    8,
    14,
    8,
    12,
    18,
    16,
    11,
    8,
    19,
    10,
    6,
    9,
    10,
    7,
    7,
    6,
    9,
    11,
    9,
    12,
    6,
    13,
    7,
    10,
    7,
    8,
    22,
    11,
    4,
    7,
    15,
    4,
    13,
    11,
    9,
    7,
    9,
    13,
    7,
    12,
    7,
    7,
    12,
    11,
    19,
    9,
    9,
    11,
    10,
    6,
    4,
    9,
    11,
    9,
    7,
    22,
    15,
    14,
    9,
    14,
    16,
    8,
    6,
    10,
    12,
    7,
    8,
    16,
    5,
    10,
    12,
    10,
    20,
    10,
    12,
    12,
    7,
    16,
    8,
    14,
    7,
    11,
    36,
    4,
    7,
    11,
    8,
    6,
    17,
    20,
    5,
    10,
    19,
    11,
    4,
    6,
    8,
    9,
    5,
    7,
    13,
    9,
    10,
    9,
    14,
    19,
    21,
    8,
    15,
    9,
    19,
    9,
    6,
    11,
    10,
    10,
    10,
    9,
    7,
    9,
    5,
    13,
    10,
    8,
    16,
    10,
    6,
    13,
    6,
    15,
    13,
    8,
    9,
    13,
    8,
    12,
    5,
    7,
    6,
    14,
    9,
    7,
    5,
    5,
    12,
    7,
    10,
    7,
    8,
    10,
    43,
    9,
    8,
    8,
    9,
    10,
    9,
    13,
    13,
    25,
    14,
    7,
    6,
    4,
    13,
    8,
    38,
    16,
    16,
    14,
    15,
    19,
    18,
    8,
    8,
    6,
    14,
    7,
    20,
    29,
    14,
    15,
    7,
    9,
    27,
    6,
    30,
    9,
    13,
    12,
    6,
    7,
    16,
    9,
    15,
    10,
    8,
    20,
    8,
    8,
    8,
    14,
    9,
    14,
    11,
    11,
    15,
    10,
    7,
    7,
    14,
    4,
    8,
    6,
    7,
    7,
    9,
    11,
    8,
    8,
    8,
    12,
    5,
    17,
    14,
    25,
    12,
    20,
    14,
    25,
    13,
    9,
    6,
    21,
    7,
    10,
    10,
    8,
    7,
    17,
    11,
    9,
    18,
    6,
    12,
    7,
    12,
    13,
    20,
    14,
    12,
    15,
    8,
    11,
    7,
    9,
    8,
    6,
    13,
    9,
    19,
    3,
    4,
    7,
    8,
    27,
    9,
    13,
    17,
    7,
    12,
    8,
    11,
    6,
    7,
    16,
    24,
    11,
    9,
    6,
    5,
    10,
    14,
    9,
    11,
    7,
    10,
    6,
    6,
    10,
    7,
    8,
    9,
    14,
    6,
    13,
    8,
    7,
    9,
    13,
    6,
    13
  ]
}

Frequently asked questions

What does the Drawdown-Recovery Markov Simulator methodology page document?
Cornish-Fisher quantile formula, simulation procedure, and references for the AI Fin Hub Drawdown-Recovery Markov simulator. It states the formulas, assumptions, data sources, limitations, and reproducibility steps behind the Drawdown-Recovery Markov Simulator, in the Finance category.
When was the Drawdown-Recovery Markov Simulator methodology last reviewed?
This methodology was last reviewed on 2026-05-08. The matching tool is at https://aifinhub.io/drawdown-recovery-markov/.
Are the Drawdown-Recovery Markov Simulator numbers reproducible?
Yes. This page embeds a worked example whose output is the verbatim result of running the shipped drawdown-recovery-markov engine on a fixed input; the embedded JSON is recomputed and diffed against the engine in CI, so the numbers cannot drift from the code.

Methodology · Tool · Last updated 2026-05-08

How Drawdown-Recovery Markov Simulator works

Monte Carlo with Cornish-Fisher quantiles to estimate time-to-recover from a drawdown — the engine behind the Drawdown-Recovery Markov simulator.

Cornish-Fisher quantile expansion

For a target distribution with skew γ₃ and excess kurtosis (γ₄ − 3), the moment-matched quantile from a standard normal z is:

q ≈ z + (z² − 1)·γ₃/6 + (z³ − 3z)·(γ₄ − 3)/24 − (2z³ − 5z)·γ₃²/36

This is the standard fourth-order expansion (Cornish-Fisher 1937). It is exact at z = 0 and accurate for moderate skew (|γ₃| ≲ 1) and excess kurtosis (γ₄ − 3 ≲ 6). Beyond those bounds the approximation distorts.

Simulation procedure

μ_m = monthly_sharpe × 0.04                           ← assume σ_m = 4%
For each path p of P:
  value = 1 − drawdown_threshold
  For t = 1..max_months:
    z = standard_normal_sample()
    q = cornish_fisher(z, γ₃, γ₄ − 3)
    r = μ_m + 0.04 · q
    value *= 1 + r
    If value ≥ 1:
      record recovery_time = t; break
  If never recovers, record never += 1

Outputs

  • 25th / 50th / 75th / 95th percentile of recovery times.
  • Probability of recovering within 12 months.
  • Probability of never recovering within the simulation cap (240 months).

Why σ_m is fixed

Time-to-recover for a given drawdown threshold depends on μ_m / σ_m (the monthly Sharpe), not σ_m alone — fixing σ_m = 4% is convenient and does not affect the result. Doubling both μ and σ yields the same recovery times.

References

  • Cornish, E. A., Fisher, R. A. (1937). "Moments and cumulants in the specification of distributions." Revue de l'Institut International de Statistique 5(4): 307–320. DOI: 10.2307/1400905.
  • Maillard, D. (2012). "A user's guide to the Cornish-Fisher expansion." SSRN 1997178.
  • Magdon-Ismail, M., Atiya, A. F. (2004). "Maximum drawdown." Risk Magazine 17(10): 99–102.
  • Burghardt, G., Duncan, R., Liu, L. (2003). "Deciphering Drawdown." Risk Magazine, September.

Limitations

  • Returns are i.i.d. by assumption — no regime switching, no autocorrelation.
  • Cornish-Fisher accuracy degrades for extreme skew/kurtosis. For very fat tails consider a t-distribution sampler.
  • Simulation cap of 240 months means very-low-Sharpe inputs will report ∞-by-cap.

External resources