Monte Carlo simulation uses randomness and the Law of Large Numbers to estimate quantities that are hard to compute analytically. A simple example is estimating π by throwing random (x,y) darts at a unit square and counting hits inside the inscribed quarter circle; the hit ratio times four approximates π, but error falls only like 1/√N so high precision requires huge sample sizes (the post notes ~10 billion samples for four-decimal reliability). Monte Carlo excels at numerical integration and high-dimensional problems. It also handles intractable combinatorics: with the 81-card game SET, there are C(81,12)=70,724,320,184,700 twelve-card hands and Knuth found 2,284,535,476,080 have no set, giving a 3.23% chance; a 10 million-run Monte Carlo reproduced 0.0323, and the same approach estimates the 15-card no-set probability at about 0.00037.
Monte Carlo is indispensable for financial projections because averages hide sequence risk and volatility. A naive deterministic model with 4% nominal return and 2% inflation gives a ~1.96% real return and would deplete $1M after ~55 years when withdrawing $30k/year, but stochastic simulations tell a different story. Running 1,000,000 trials that draw returns and inflation from realistic distributions shows wide variation: 25% of scenarios exhaust funds by ~22 years and only about 60% last 30 years, revealing substantially higher risk than the simple average implies. All code for the examples is available on GitHub.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.