University / ProfessionalLessonProbability & simulation
Monte Carlo: Solving the Unsolvable by Rolling Dice
How Monte Carlo methods turn unsolvable integrals into dice rolls — from Ulam's solitaire hunch to pricing options and rendering every Pixar frame.
dailymath · · 9 min read
In 1946, the mathematician Stanislaw Ulam was laid up in Los Angeles, recovering from a bout of encephalitis, killing time with hand after hand of Canfield solitaire. Bored enough to actually think about the game instead of just playing it, he found himself wondering something sharper than idle curiosity: what fraction of Canfield deals can actually be won? He tried the honest way first — enumerate the possible sequences of plays and work out the exact combinatorics — and ran straight into a wall. Fifty-two cards and a long tree of choices blow the state space up past anything you could hope to count by hand, and the "just solve it with algebra" instinct that works for a coin flip collapses completely.
The reframe that followed is the one Ulam is actually remembered for. Don't compute the probability of winning — *estimate* it. Deal out the cards a hundred times, actually or on paper, and count how many hands come out. The fraction of successes is your answer: noisy, not exact, but obtainable in an afternoon instead of never. He described the idea to John von Neumann, who saw immediately that it generalized far past card games — any quantity you can write as an average has a stand-in, and you don't need a formula for it, only a way to sample. His Los Alamos colleague Nicholas Metropolis gave the method its name, borrowed from the Monte Carlo casino, where Ulam had an uncle who would reliably borrow money from relatives because, as Ulam put it, he simply had to go gamble there. The name stuck for the obvious reason: this is a method built out of rolling dice on purpose, as a way of doing arithmetic.
That's the whole idea, and it stretches from a dartboard to a derivatives desk without changing shape: when the integral you need is impossible — too many dimensions, no closed form, a boundary too irregular to write down — stop trying to solve it exactly. Simulate it instead. The rest of this piece is that one idea worked through three times: once with actual darts, once with the formula for how fast the guessing gets good, and once with the machinery a real trading desk runs every day.
The reframe that followed is the one Ulam is actually remembered for. Don't compute the probability of winning — *estimate* it. Deal out the cards a hundred times, actually or on paper, and count how many hands come out. The fraction of successes is your answer: noisy, not exact, but obtainable in an afternoon instead of never. He described the idea to John von Neumann, who saw immediately that it generalized far past card games — any quantity you can write as an average has a stand-in, and you don't need a formula for it, only a way to sample. His Los Alamos colleague Nicholas Metropolis gave the method its name, borrowed from the Monte Carlo casino, where Ulam had an uncle who would reliably borrow money from relatives because, as Ulam put it, he simply had to go gamble there. The name stuck for the obvious reason: this is a method built out of rolling dice on purpose, as a way of doing arithmetic.
That's the whole idea, and it stretches from a dartboard to a derivatives desk without changing shape: when the integral you need is impossible — too many dimensions, no closed form, a boundary too irregular to write down — stop trying to solve it exactly. Simulate it instead. The rest of this piece is that one idea worked through three times: once with actual darts, once with the formula for how fast the guessing gets good, and once with the machinery a real trading desk runs every day.
Fig. 1 · π from 400 darts
inside (x² + y² ≤ 1)
outside
Why counting darts computes an integral
Set up a unit square and inscribe a quarter circle of radius 1 in one corner. The square has area 1; the quarter circle has area — that's just scaled down by a factor of four for one quadrant. Throw darts uniformly at random inside the square, and each dart has probability exactly of landing inside the quarter circle, since probability for a uniform distribution over a region is nothing but area. Throw enough darts and count what fraction land inside, and that fraction has to settle down near — this is the law of large numbers doing its ordinary job, the same reason a fair coin flipped a million times lands close to half heads.
Multiply the fraction by 4 and you have an estimate of π:
Multiply the fraction by 4 and you have an estimate of π:
It looks like a party trick, but the mechanism underneath is completely general. Being "inside the quarter circle" is just an indicator function — 1 if , 0 otherwise — and its average value over the square is exactly its integral over the square. Swap that indicator for *any* function , and the same trick estimates : sample points at random from wherever you're integrating over, average at those points, and the average converges to the true integral as the sample grows. An integral is an expected value wearing a different name, and once you see that, Monte Carlo stops being a curiosity about darts and starts being a general-purpose way to compute any integral you can sample from, no matter how ugly its shape.
The 1/√N law: curse and miracle
How fast does the dart estimate actually converge? The central limit theorem answers precisely: the error of a Monte Carlo estimate built from samples shrinks like
where is the standard deviation of whatever you're averaging — for the dart game, a fixed number close to 0.4. That is a curse and a miracle in the same breath. The curse: convergence is slow. To knock one more correct decimal digit off your error — shrink it by a factor of 10 — you need times as many samples. Monte Carlo is not a fast way to get a lot of digits.
The miracle is what that rate *doesn't* mention: dimension. Grid-based quadrature — laying down evenly spaced points and summing — needs evaluations to place points along each of axes, so ten points per axis in 100 dimensions is evaluations, more than there are atoms in the observable universe. Monte Carlo's error still shrinks as regardless of . That's not a free lunch — itself, the spread of the quantity you're averaging, can genuinely grow as the problem gets higher-dimensional and messier, so the constant in front of isn't guaranteed to stay small. But the *rate* — the exponent on — never picks up a dependence on the way a grid's does. That single fact is why finance, pricing payoffs that depend on baskets of dozens of correlated assets, and physics, evaluating path integrals over infinitely many degrees of freedom, have no real alternative to sampling. Nothing else scales. A quant pricing an option on ten correlated stocks, or a physicist integrating over every possible path a particle could take, is not choosing Monte Carlo out of laziness — a grid over that many dimensions was never on the table to begin with.
The miracle is what that rate *doesn't* mention: dimension. Grid-based quadrature — laying down evenly spaced points and summing — needs evaluations to place points along each of axes, so ten points per axis in 100 dimensions is evaluations, more than there are atoms in the observable universe. Monte Carlo's error still shrinks as regardless of . That's not a free lunch — itself, the spread of the quantity you're averaging, can genuinely grow as the problem gets higher-dimensional and messier, so the constant in front of isn't guaranteed to stay small. But the *rate* — the exponent on — never picks up a dependence on the way a grid's does. That single fact is why finance, pricing payoffs that depend on baskets of dozens of correlated assets, and physics, evaluating path integrals over infinitely many degrees of freedom, have no real alternative to sampling. Nothing else scales. A quant pricing an option on ten correlated stocks, or a physicist integrating over every possible path a particle could take, is not choosing Monte Carlo out of laziness — a grid over that many dimensions was never on the table to begin with.
Fig. 2 · Error vs sample count
seed 42
seed 7
seed 1999
1/√n reference
The quant's workhorse: simulating prices
The model quants reach for to describe a stock price's random wander is geometric Brownian motion (GBM): the price never goes negative, and its percentage moves, not its absolute moves, are what's roughly Gaussian. One simulation step looks like this:
Draw a fresh standard normal at every step, apply the update, and you get one possible future for the price. Draw thousands of independent price paths this way and you get a whole fan of futures — which is exactly what a Monte Carlo option-pricing engine does, because most options that actually trade have no closed-form price. Anything path-dependent, or written on a basket of several assets at once, or exercisable at times a formula can't cleanly capture — simulate a large number of paths, evaluate the payoff at the end of each one, and average.
Honesty matters here: a real pricing desk does not simulate under the drift that historical data suggests the stock has — real-world drift turns out not to matter for a no-arbitrage price at all. It simulates under the *risk-neutral* measure, replacing with the risk-free rate, then discounts the average payoff back to today at that same rate. Risk-neutral drift plus discounting, together, is the actual recipe; either piece alone gives you the wrong number. That's a subtlety worth sitting with: the price a desk quotes does not depend on whether the trader thinks the stock is going up — it depends only on the volatility , the risk-free rate, and the payoff's shape. Two traders with wildly different opinions about where the stock is headed still agree on the option's arbitrage-free price, because both of them are, correctly, simulating under the same risk-neutral drift.
Honesty matters here: a real pricing desk does not simulate under the drift that historical data suggests the stock has — real-world drift turns out not to matter for a no-arbitrage price at all. It simulates under the *risk-neutral* measure, replacing with the risk-free rate, then discounts the average payoff back to today at that same rate. Risk-neutral drift plus discounting, together, is the actual recipe; either piece alone gives you the wrong number. That's a subtlety worth sitting with: the price a desk quotes does not depend on whether the trader thinks the stock is going up — it depends only on the volatility , the risk-free rate, and the payoff's shape. Two traders with wildly different opinions about where the stock is headed still agree on the option's arbitrage-free price, because both of them are, correctly, simulating under the same risk-neutral drift.
Fig. 3 · 30 futures for one stock
simulated paths
mean of 30 paths
start price
Where the dice roll
Option desks price exotic derivatives this way and risk teams estimate Value at Risk by simulating thousands of portfolio scenarios. Actuaries reserve for insurance losses by simulating claim distributions instead of solving for them. Reliability engineers simulate component failure times to estimate a system's odds of surviving a mission. Every frame Pixar renders traces thousands of randomly sampled light paths per pixel to approximate the physics of how light actually bounces. Epidemiologists simulate outbreaks across a population instead of solving the underlying equations exactly. And Go and poker engines search their game trees by Monte Carlo tree search — playing out random continuations and counting who tends to win.
Two habits separate a Monte Carlo simulation you can trust from one you can't. First, seed it, and keep the seed. A simulation driven by a pseudo-random number generator seeded with a fixed value produces the exact same sequence of "random" numbers every time it runs, which turns an otherwise unrepeatable experiment into something you can debug, diff, and hand to a colleague who gets your exact numbers back. Second, know that the rate is not the last word on cost — a family of variance reduction techniques exists specifically to shrink itself: antithetic variates pair each random draw with its mirror image to cancel noise, control variates lean on a correlated quantity you already know the answer to, and quasi-random (low-discrepancy) sequences replace pure randomness with more evenly spread points. Each can cut the practical cost by a large constant factor. None of them changes the exponent — that rate is structural, not a matter of cleverness.
1
Check your intuition
Question 1 of 4
You want one more decimal digit of accuracy from a Monte Carlo estimate. Roughly how many more samples?
Monte Carlo is what's left when an exact answer is out of reach but a sample isn't — trade the formula you can't write for a die you can roll a million times. If chasing that kind of intuition down to the arithmetic is your thing, solve a fresh math problem every morning with dailymath. One drop, one coffee, one win.
Try dailymath