Randomness Is a Tool, Not a Bug
Monte Carlo methods, MCMC, stochastic differential equations. There's something philosophically strange about using randomness to compute deterministic things. Maybe that's why I like it.
I remember sitting in STAT 340 (Univ. of Waterloo) and spending the entire first week on pseudo-random number generation. How computers produce "random" numbers. The professor walked us through linear congruential generators: take a seed, multiply it by some constant, add another constant, take a modulus, repeat. You get a sequence of numbers that looks random but is completely deterministic. Run it twice with the same starting point and you get the exact same numbers in the same order every time.
This was almost philosophically offensive. I mean, the whole point of randomness is that it's unpredictable. It's uncertain. It's why I could never relax when I was a kid and why I still get anxious when I'm waiting for the outcome of anything. But a computer is a deterministic machine, so how can it create something random? True randomness requires reaching outside of the machine and relying on the scary world around us: hardware entropy sources, atmospheric noise, and quantum measurements.
What I didn't appreciate yet was how much careful work goes into making pseudo-randomness actually good. Decades of research has made sure that modern pseudo-random number generators pass every statistical test that we know how to run. The irony is that they have to be carefully engineered to not be too regular, because pure mathematical sequences have structure that real randomness doesn't. Getting that right turns out to be genuinely hard, but that's a can of worms for another day.
I was fascinated by the idea that you could build something deterministic that behaved enough like true randomness to become useful.
Monte Carlo Integration
You want to compute ∫Ω f(x) dx for some high-dimensional domain Ω. Analytic methods fail when the dimension is large; the curse of dimensionality makes it exponentially expensive. But if you can draw samples x1, ..., xn from a uniform distribution over Ω, then:
We can just take a bunch of samples and average them together to see how much area under the curve we've covered. The canonical Monte Carlo convergence rate is O(n−1/2). That is slow, since you need 100× more samples to get 10× more precision, but unlike grid-based quadrature, the rate itself does not explicitly worsen with dimension. The variance of the function still matters, but for high-dimensional integrals, this is often the only practical option.
Markov Chain Monte Carlo
Most processes in the world aren't conveniently uniformly distributed though. But we can still navigate them just by comparing two points at a time. We don't need absolute probabilities; we just need to know which option is better.
This is exactly what happens in Bayesian inference: you have a posterior p(θ|data) ∝ p(data|θ)p(θ), you can compute the right-hand side for any θ, but you can't easily draw samples from the left-hand side.
MCMC constructs a Markov chain whose stationary distribution is the target. The Metropolis-Hastings algorithm: propose a new state θ' from a proposal distribution q(θ'|θ). Accept with probability:
Reject otherwise, staying at θ. This works because the acceptance ratio is constructed to satisfy the detailed balance:
where π is the target distribution and T is the transition probability. Any chain satisfying this detailed balance has π as its stationary distribution.
Modern variants and where they can be used
Gradient descent seems to be trendy these days. Hamiltonian Monte Carlo (HMC) uses gradient information to make proposals that move further before being rejected, which works well in high dimensions. Stochastic gradient methods extend this to larger datasets. Stochastic gradient Langevin dynamics, for instance, adds Gaussian noise to stochastic gradient descent updates in a way that provably samples from the posterior (approximately). This is how you do Bayesian inference when your data doesn't fit in memory.
Sequential Monte Carlo (particle filtering) handles dynamical systems: time-series models where you want to update your posterior over a latent state as new observations arrive. It's used in tracking, signal processing, and fitting physiological models to wearable data streams, which is relevant to a lot of what I think about.
The mindset it teaches
Working seriously with Monte Carlo methods changes how I think about uncertainty. It's almost comforting since we don't have to be so sure about everything. When you're sampling from a distribution rather than computing a point estimate, you're also forced to think about the full distribution of outcomes and what the whole picture looks like. What's the variance? Are there heavy tails? Is the distribution bimodal?
The algorithms that utilize randomness are often simpler, faster, and more broadly applicable than their deterministic counterparts. Understanding why changes how you think about what computation is for.
Why this matters beyond the math
I think about stochastic simulation a lot when I think about how to make sense of the world. The deterministic instinct we've all been taught in school (find what to do and solve for x) breaks down almost everywhere that matters. Biology doesn't have closed-form solutions. Financial markets don't. Human behavior doesn't. The systems we usually want to understand the most are the ones where the dynamics are too complex, too high-dimensional, or too nonlinear for a clear-cut solution.
Today, we have more data coming in every second than we know how to deal with. Simulation is how we can reason about these complex systems. We don't pretend we have a clear answer. We run scenarios millions of times and look at the distribution of outcomes: not just the mean, the entire spread, the tails, the cases where everything goes wrong, and the cases where everything goes extremely right.
Elite athletes practice this all the time. They do not visualize one perfect outcome; they rehearse a distribution of possible scenarios and prepare for each one. Most people want a final answer. Stochastic simulation trains us to want something more useful: a probability distribution over what might happen, conditioned on what we already know. That's more work to communicate and harder to act on, but it's a more honest representation of where we stand. And it helps some of us relax a little bit more.
Written by Elisa Casella.
← Back to all writing