Sub topic 14
Test the plan with a Monte Carlo simulation
This chapter assumes you can read basic Python. It also assumes you know how to turn a spending gap into a target nest egg with a withdrawal rate, and that you know the difference between real and nominal dollars. Earlier chapters built a single target number. Here you test how fragile that number is.
Why one average return is not enough
A projection that uses a constant 5% real return answers the question "what happens if every year is average?" Real markets are not average every year. Returns come in a different order each time, and the order matters once you start withdrawing money. A bad first few years hurts more than the same bad years late in retirement, because you sell assets at low prices and have less left to recover.
A Monte Carlo simulation replaces the single path with thousands of random paths. Each path draws a return for every year, applies the withdrawal, and records whether money remained at the end. The share of paths that survive is a rough measure of how robust the plan is.
The method is named after the casino. It uses repeated random sampling to estimate something that is hard to calculate directly.
What goes into the simulation
You supply five inputs, and each one is an assumption, not a fact.
| Input | Meaning | Example |
|---|---|---|
| Starting balance | Savings on the day you retire | 900,000 |
| Annual withdrawal | Spending gap in today's dollars | 36,000 |
| Horizon | Years the money must last | 30 |
| Mean real return | Average yearly return after inflation | 5% |
| Standard deviation | How widely yearly returns vary | 12% |
Everything is in real dollars. That is why the withdrawal stays fixed in the code. A constant real withdrawal is the same as a nominal withdrawal that rises with inflation. If you mixed nominal returns with a fixed nominal withdrawal, the plan would look better than it is, because it would ignore the rising cost of living.
The standard deviation measures volatility. With a mean of 5% and a standard deviation of 12%, about two thirds of yearly returns land between -7% and +17%. The remaining third lands outside that range.
The simulation loop
The order inside each year is a modeling choice. The code below withdraws first and then applies the return. This is a mildly conservative convention, because the money withdrawn does not earn growth that year. Withdrawing at the end of the year gives slightly better results.
A working simulation
This is the function from the plan, with a worked call.
import random
def success_rate(start, annual_withdrawal, years,
mean_real_return=0.05, stdev=0.12,
trials=10_000, seed=1):
"""Share of simulated retirements that do not run out of money."""
rng = random.Random(seed)
successes = 0
for _ in range(trials):
balance = start
for _ in range(years):
balance -= annual_withdrawal
if balance <= 0:
break
balance *= 1 + rng.gauss(mean_real_return, stdev)
else:
successes += 1
return successes / trials
rate = success_rate(start=900_000, annual_withdrawal=36_000, years=30)
print(f"Plan survived in {rate:.0%} of simulated runs")A few details are worth understanding.
random.Random(seed)creates a private random generator. With a fixed seed, the result is the same on every run, so you can compare two plans fairly. Change the seed to see how much the answer shifts from sampling noise alone.rng.gauss(mean, stdev)draws from a normal distribution. This is a simplification, and a later section explains its limits.- The
for ... elseconstruct runs theelseblock only when the inner loop finishes withoutbreak. A trial counts as a success only if it survives every year. - Ten thousand trials give a stable estimate. With far fewer, say 100, the success rate can move by several percentage points between seeds.
Reading the result
The output is a probability, not a promise. A result such as "survived in 90% of runs" means that under these assumptions, about one in ten simulated retirements ran out of money. It does not mean you have a 90% chance in real life, because the real chance depends on whether the assumptions describe the future.
There is no universal passing score. Many planners treat results in the high 80s to low 90s percent as reasonable and look harder at anything lower. Lower is acceptable if you have flexibility, such as the ability to cut spending in a bad market. A higher target makes sense if your spending is mostly fixed and you have no other income to fall back on.
Failure is also not all-or-nothing. A plan that runs out at age 93 is different from one that runs out at age 78. If you want more detail, record the year of failure, not only whether it happened.
Sweeping assumptions
One run tells you little. The value comes from changing one input at a time and watching how the success rate responds. This standalone script varies the withdrawal rate and also reports the median ending balance.
import random
import statistics
def simulate(start, withdrawal, years, mean=0.05, stdev=0.12,
trials=10_000, seed=1):
"""Return the ending real balance of each trial (0 if money ran out)."""
rng = random.Random(seed)
endings = []
for _ in range(trials):
balance = start
for _ in range(years):
balance -= withdrawal
if balance <= 0:
balance = 0
break
balance *= 1 + rng.gauss(mean, stdev)
endings.append(balance)
return endings
start = 900_000
for rate in (0.03, 0.035, 0.04, 0.045, 0.05):
endings = simulate(start, start * rate, years=30)
ok = sum(e > 0 for e in endings) / len(endings)
median = statistics.median(endings)
print(f"{rate:.1%} withdrawal: {ok:.0%} success, "
f"median ending balance {median:,.0f}")The success rate falls as the withdrawal rate rises, and the pattern is usually more informative than any single line. Look for where the curve bends. If going from 4.0% to 4.5% costs several points of success, the plan is sensitive in that range. You can run the same sweep over the horizon, the mean return, or the standard deviation.
The median ending balance is also useful. In successful plans it is often large, which shows that many paths leave money unspent. That is the price of protecting against the bad paths.
Limits of the method
Monte Carlo output looks precise, so it invites more trust than it deserves. Keep these weaknesses in mind.
- The inputs are guesses. The mean return and volatility are assumptions. Changing the mean from 5% to 4% can move the result more than any other change. Test both optimistic and pessimistic values.
- Returns are not independent and normal. Real markets show crashes more often than a normal distribution implies, and returns sometimes cluster, such as long slumps. The simple model understates tail risk.
- Spending is rigid in the model. Real retirees adjust. They skip a raise, travel less, or work part-time after a market drop. A model with fixed withdrawals is harsher than real behavior, so it understates how well a flexible plan holds up.
- It ignores taxes, healthcare and one-off costs unless you build them into the withdrawal amount. A large late-life care cost is better modeled as a separate event than averaged into the annual figure.
- A single asset class. One mean and one standard deviation stand in for a whole portfolio. Mixes of stocks and bonds, with rebalancing, need a richer model.
An alternative to random draws is historical simulation. It replays actual sequences of past returns, such as starting a retirement in 1966. It captures real clustering and crashes but has a small sample, because there are only so many distinct 30-year windows. Using both methods is a sensible cross-check.
Using the result in your plan
Treat the simulation as a stress test of the target nest egg, not as a replacement for it. A practical routine:
- Compute the target nest egg from the spending gap and a withdrawal rate.
- Run the simulation at that balance with your horizon and cautious assumptions.
- If the success rate is lower than you want, change one lever at a time: save more, retire later, lower planned spending, or add guaranteed income.
- Rerun and record the result with the date and the assumptions you used.
The last step feeds the review routine in the next chapter. When your balance, spending or the market changes, you rerun the same script and compare it with the earlier result.
Exercise
In success_rate, why does the code subtract the withdrawal before applying the random return, and what happens to the result if you reverse the order?
Show answer
Withdrawing first means the money taken out does not earn that year's return, which is a slightly conservative assumption. If you apply the return first and withdraw at the end of the year, the whole balance grows for one more period, so the success rate rises a little. Neither order is wrong, but you should pick one deliberately and keep it the same when comparing plans.
Exercise
A simulation with 100 trials gives 94% success with seed 1 and 89% with seed 2. What does that tell you, and how would you fix it?
Show answer
The estimate is dominated by sampling noise, since 100 trials is too few for a stable probability. Increase the trials to 10,000 or more and confirm that different seeds give results within a point or two of each other. Compare plans only when they use the same seed and trial count.
Exercise
You change the mean real return from 5% to 3.5% and the success rate drops sharply. Does this mean the plan is bad?
Show answer
Not necessarily. It shows that the plan is sensitive to the return assumption. That is useful information. Decide whether 3.5% is a plausible downside, then consider levers such as a lower withdrawal rate, a later retirement date, or a rule to cut spending after bad years. If the plan only passes under the higher return, treat it as fragile.