{"id":3512,"date":"2026-03-11T15:49:05","date_gmt":"2026-03-11T14:49:05","guid":{"rendered":"https:\/\/www.gironi.it\/blog\/?p=3512"},"modified":"2026-07-12T08:35:30","modified_gmt":"2026-07-12T07:35:30","slug":"the-monte-carlo-method-explained-simply-with-real-world-applications","status":"publish","type":"post","link":"https:\/\/www.gironi.it\/blog\/en\/the-monte-carlo-method-explained-simply-with-real-world-applications\/","title":{"rendered":"The Monte Carlo Method Explained Simply with Real-World Applications"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"cose\">What is the Monte Carlo method<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The story of the Monte Carlo method begins in the most unlikely way: with a mathematician in bed playing cards. In 1946, <strong>Stanis\u0142aw Ulam<\/strong>, a Polish mathematician recovering from surgery, found himself playing solitaire to pass the time. Being a mathematician, he wondered: what are the chances of winning a game?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The problem was theoretically solvable: just enumerate every possible combination of cards and count the favorable ones. In practice, however, the number of combinations was so enormous that an exact calculation was completely impractical. Ulam then had an insight as simple as it was powerful: <strong>instead of computing the exact probability, why not simulate hundreds of games and count how many times you win?<\/strong><\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\">The idea is disarmingly simple. If we play 1,000 games and win 230 of them, we can estimate the probability of winning at about 23%. The more games we simulate, the closer our estimate gets to the true value. This is, in essence, the <strong>Monte Carlo method<\/strong>: using random simulation to solve problems that would be too complex to tackle analytically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ulam shared the idea with his colleague <strong>John von Neumann<\/strong>, arguably the most brilliant mathematician of the 20th century, who immediately saw its potential. Von Neumann realized that <strong>ENIAC<\/strong> \u2014 one of the very first electronic computers, which filled an entire room \u2014 could run thousands of simulations in reasonable time. Together, they developed the method for a problem far more serious than solitaire: the <strong>diffusion of neutrons<\/strong> in atomic weapons, as part of the Manhattan Project at Los Alamos.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The name &#8220;Monte Carlo&#8221; was chosen as a code name, a reference to the famous <strong>Monte Carlo Casino<\/strong> in Monaco. Legend has it that the inspiration came from Ulam&#8217;s uncle, a notorious gambler. After all, the heart of the method is chance itself: generating random numbers to explore spaces of possibility too vast to traverse systematically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From those early nuclear experiments of the 1940s, the Monte Carlo method has spread to every field of science and engineering. Today it is one of the most widely used computational tools in the world, from particle physics to finance, from cinematic rendering to drug discovery. Let&#8217;s see how it works.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What we&#8217;ll cover:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"#cose\">What is the Monte Carlo method<\/a><\/li><li><a href=\"#concetti\">Preliminary concepts: chance, large numbers, convergence<\/a><\/li><li><a href=\"#quattro-passi\">The method in four steps<\/a><\/li><li><a href=\"#esempio-pi\">Example 1 \u2014 estimating \u03c0 with random numbers<\/a><\/li><li><a href=\"#esempio-portafoglio\">Example 2 \u2014 the risk of a portfolio<\/a><\/li><li><a href=\"#esempio-seo\">Example 3 \u2014 how many clicks does climbing the rankings really bring<\/a><\/li><li><a href=\"#simulatore\">The simulator: geometric Brownian motion<\/a><\/li><li><a href=\"#applicazioni\">Where the Monte Carlo method is used today<\/a><\/li><li><a href=\"#limiti\">Advantages, limits and the caveat to remember<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"concetti\">Preliminary concepts: chance, large numbers, convergence<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Monte Carlo method rests on a statistical principle we&#8217;ve encountered before: the <a href=\"https:\/\/www.gironi.it\/blog\/en\/central-limit-theorem\/\">law of large numbers<\/a>. In simple terms, this law tells us that the average of a random sample approaches the population average as the sample grows. Translated into Monte Carlo language: <strong>the more simulations we run, the more accurate our result will be<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To run a Monte Carlo simulation, we need <strong>random numbers<\/strong>. In practice, computers don&#8217;t generate truly random numbers: they use deterministic algorithms that produce sequences of <strong>pseudo-random numbers<\/strong> with statistical properties indistinguishable from real randomness.<br>In R, for example, the <code>runif()<\/code> function generates uniformly distributed numbers between 0 and 1. Their being deterministic has a valuable upside: by fixing the seed with <code>set.seed()<\/code>, anyone who re-runs the same code gets exactly the same numbers \u2014 which is why the results we&#8217;re about to see are reproducible to the decimal.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A crucial aspect is the <strong>rate of convergence<\/strong>. The Monte Carlo estimation error decreases as <strong>1\/\u221an<\/strong>, where n is the number of simulations. This means that to halve the error, we need to quadruple our simulations; to gain one more decimal digit of precision, we need 100 times more iterations.<br>It&#8217;s not particularly efficient, but the beauty of the method lies in the fact that <strong>it works regardless of the problem&#8217;s complexity<\/strong>: whether the problem has 2 or 2,000 variables, the convergence rate remains the same.<\/p>\n\n\n\n<div class=\"wp-block-group has-background\" style=\"background-color:#f5f7f9;margin-top:2.5rem;margin-bottom:2.5rem;padding-top:1.5rem;padding-right:1.5rem;padding-bottom:1rem;padding-left:1.5rem\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-container-core-group-is-layout-eed7543b wp-block-group-is-layout-constrained\">\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1140\" height=\"585\" src=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-convergenza-en.png\" alt=\"On the left the estimate of \u03c0 settles as the number of simulations grows; on the right the typical error falls along the 1\/\u221an line, measured over many independent repetitions.\" class=\"wp-image-4085\" srcset=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-convergenza-en.png 1140w, https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-convergenza-en-300x154.png 300w, https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-convergenza-en-1024x525.png 1024w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption class=\"wp-element-caption\">On the left the estimate of \u03c0 settles as the number of simulations grows; on the right the typical error falls along the 1\/\u221an line, measured over many independent repetitions.<\/figcaption><\/figure>\n\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">In practice, we must always balance <strong>desired precision<\/strong> with <strong>available computational resources<\/strong>. Increasing the number of simulations comes at a cost in computation time. Fortunately, modern computers make this trade-off much more favorable than in the days of ENIAC.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"quattro-passi\">The method in four steps<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s see concretely how the Monte Carlo method is applied. The procedure follows four fundamental steps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. Define the model.<\/strong> First, we identify the problem&#8217;s variables and the probability distributions that govern them. For instance, if we want to simulate an investment&#8217;s return, the model will include the expected return (mean) and volatility (standard deviation), typically assuming <a href=\"https:\/\/www.gironi.it\/blog\/en\/the-normal-distribution\/\">normally distributed<\/a> returns.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Generate random scenarios.<\/strong> Using a pseudo-random number generator, we produce thousands of possible scenarios. Each scenario represents an &#8220;alternative history&#8221;: one way things could play out.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Compute the result for each scenario.<\/strong> For each scenario, we apply the model and obtain a result. If we&#8217;re simulating an investment, the result is the final portfolio value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>4. Aggregate the results.<\/strong> Finally, we analyze the set of results: we compute the mean, the median, the percentiles. This gives us not just an estimate of the expected outcome, but an entire <strong>distribution of possibilities<\/strong>. And this is where Monte Carlo truly shines: it tells us not only &#8220;how much we&#8217;re likely to earn&#8221; but also &#8220;how much we could lose in the worst case.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s use a quick example to illustrate convergence. Imagine flipping a coin and trying to estimate the probability of heads. After 10 flips, we might get 7 heads (70%), an estimate far from the true 50%. After 100 flips, we&#8217;ll be closer, perhaps 53%. After 10,000 flips, our estimate will be very close to 50%. This is Monte Carlo in action: replacing a theoretical calculation with an experiment repeated thousands of times.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The power of the method lies in its <strong>flexibility<\/strong>. While analytical methods require closed-form solutions (which often don&#8217;t exist for complex problems), Monte Carlo only requires the ability to simulate the process. If we can write a program that generates one scenario, Monte Carlo gives us the distribution of outcomes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esempio-pi\">Example 1 \u2014 estimating \u03c0 with random numbers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The most classic and pedagogically effective example of the Monte Carlo method is <strong>estimating the number \u03c0<\/strong>. The idea is elegant: consider a square of side 2 with a circle of radius 1 inscribed inside it. The area of the square is 4, the area of the circle is \u03c0. If we generate random points inside the square, the proportion falling inside the circle will be approximately \u03c0\/4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I compute this in R with 100,000 points:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set.seed(123)\nn &lt;- 100000\nx &lt;- runif(n, -1, 1)\ny &lt;- runif(n, -1, 1)\ninside &lt;- (x^2 + y^2) &lt;= 1\npi_estimate &lt;- 4 * sum(inside) \/ n\npi_estimate\n# [1] 3.14632<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The same in Python:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import random\nrandom.seed(123)\nn = 100000\ninside = sum(1 for _ in range(n)\n             if random.uniform(-1, 1)**2 + random.uniform(-1, 1)**2 &lt;= 1)\npi_estimate = 4 * inside \/ n\nprint(pi_estimate)\n# 3.13688<\/code><\/pre>\n\n\n\n<div class=\"wp-block-group has-background\" style=\"background-color:#f5f7f9;margin-top:2.5rem;margin-bottom:2.5rem;padding-top:1.5rem;padding-right:1.5rem;padding-bottom:1rem;padding-left:1.5rem\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-container-core-group-is-layout-eed7543b wp-block-group-is-layout-constrained\">\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"810\" height=\"810\" src=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-pi-punti-en.png\" alt=\"100,000 random points in the square: the share falling inside the inscribed circle, multiplied by 4, estimates \u03c0 (here 3.146).\" class=\"wp-image-4086\" srcset=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-pi-punti-en.png 810w, https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-pi-punti-en-300x300.png 300w, https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-pi-punti-en-150x150.png 150w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><figcaption class=\"wp-element-caption\">100,000 random points in the square: the share falling inside the inscribed circle, multiplied by 4, estimates \u03c0 (here 3.146).<\/figcaption><\/figure>\n\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">With 100,000 points we already get a reasonable estimate, though not extremely precise: we&#8217;re accurate to about two decimal places. As we can see, R and Python start from the same seed but use different generators and land on slightly different numbers (3.146 versus 3.137): both dance around the true \u03c0 by the amount the 1\/\u221an curve predicts. Gaining another digit of precision would require roughly 100 times more points. The computer does all the heavy lifting.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esempio-portafoglio\">Example 2 \u2014 the risk of a portfolio<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s move to an example closer to real-world applications. Suppose we have a portfolio of three stocks with the following characteristics:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Stock<\/th><th>Expected return<\/th><th>Standard deviation<\/th><th>Portfolio weight<\/th><\/tr><\/thead><tbody><tr><td>A<\/td><td>8%<\/td><td>12%<\/td><td>40%<\/td><\/tr><tr><td>B<\/td><td>10%<\/td><td>15%<\/td><td>30%<\/td><\/tr><tr><td>C<\/td><td>12%<\/td><td>18%<\/td><td>30%<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We want to estimate the probability that the portfolio return exceeds 10%. I simulate in R with 10,000 scenarios:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set.seed(42)\nsim_A &lt;- rnorm(10000, mean = 0.08, sd = 0.12)\nsim_B &lt;- rnorm(10000, mean = 0.10, sd = 0.15)\nsim_C &lt;- rnorm(10000, mean = 0.12, sd = 0.18)\nsim_portfolio &lt;- 0.4 * sim_A + 0.3 * sim_B + 0.3 * sim_C\nprob_result &lt;- mean(sim_portfolio &gt;= 0.10)\nprob_result\n# [1] 0.4903<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The same in Python:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import random\nrandom.seed(42)\nn = 10000\ncount = 0\nfor _ in range(n):\n    a = random.gauss(0.08, 0.12)\n    b = random.gauss(0.10, 0.15)\n    c = random.gauss(0.12, 0.18)\n    ptf = 0.4 * a + 0.3 * b + 0.3 * c\n    if ptf &gt;= 0.10:\n        count += 1\nprint(count \/ n)\n# 0.4898<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The result tells us there&#8217;s roughly a 49% chance of exceeding a 10% return. But the truly valuable thing is not this single number: it&#8217;s the <strong>entire distribution<\/strong> that Monte Carlo puts before our eyes. From it we also read the median return, the worst-case 5th percentile and \u2014 anything but a minor detail \u2014 the probability of closing at a loss, which here is close to 13%.<\/p>\n\n\n\n<div class=\"wp-block-group has-background\" style=\"background-color:#f5f7f9;margin-top:2.5rem;margin-bottom:2.5rem;padding-top:1.5rem;padding-right:1.5rem;padding-bottom:1rem;padding-left:1.5rem\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-container-core-group-is-layout-eed7543b wp-block-group-is-layout-constrained\">\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1020\" height=\"660\" src=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-portafoglio-en.png\" alt=\"The 10,000 simulated portfolio returns: about 49% exceed the 10% target, about 13% close at a loss.\" class=\"wp-image-4087\" srcset=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-portafoglio-en.png 1020w, https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-portafoglio-en-300x194.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption class=\"wp-element-caption\">The 10,000 simulated portfolio returns: about 49% exceed the 10% target, about 13% close at a loss.<\/figcaption><\/figure>\n\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esempio-seo\">Example 3 \u2014 how many clicks does climbing the rankings really bring<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">So far physics and finance; but Monte Carlo is at home in our field too. Let&#8217;s use a quick example. We&#8217;re weighing whether it&#8217;s worth investing to move a page from ninth position to third on an interesting keyword. The client&#8217;s question is blunt: &#8220;how many extra clicks does it bring?&#8221;. The temptation is to answer with a back-of-the-envelope figure \u2014 average monthly impressions times average CTR in third position:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>12000 * 0.11\n# [1] 1320<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Thirteen hundred clicks a month, a clean and reassuring number. Too bad it&#8217;s <strong>falsely precise<\/strong>: it hides two uncertainties the size of a house. Impressions are not a constant \u2014 they swing with seasonality and market demand \u2014 and the <a href=\"https:\/\/www.gironi.it\/blog\/en\/expected-vs-actual-ctr\/\">expected CTR<\/a> in third position is not a fixed number, but depends on the SERP, on the presence of elements like AI Overviews, on search intent. Instead of multiplying two averages, we feed Monte Carlo the uncertainty of both.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I simulate ten thousand scenarios in R, with impressions around 12,000 (standard deviation 2,500) and CTR around 11% (standard deviation 3 points):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set.seed(7)\nn &lt;- 10000\nimpressions &lt;- rnorm(n, mean = 12000, sd = 2500)\nimpressions[impressions &lt; 0] &lt;- 0\nctr &lt;- rnorm(n, mean = 0.11, sd = 0.03)\nctr[ctr &lt; 0] &lt;- 0\nclicks &lt;- impressions * ctr\n\nmean(clicks)                     # ~ 1323 clicks\/month\nmedian(clicks)                   # ~ 1282\nquantile(clicks, c(0.05, 0.95))  # ~ 632 ... 2139\nmean(clicks &gt; 1500)              # ~ 0.33<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The mean (about 1,320 clicks) matches the back-of-the-envelope figure, and so far no surprise. But the simulation adds exactly what the single number erased: the plausible scenarios range from <strong>about 630 to about 2,140 clicks a month<\/strong>, and if the project only breaks even above 1,500 clicks, the probability of clearing that bar is barely one in three. It&#8217;s the same histogram as the portfolio example, applied to clicks instead of returns \u2014 and it tells a story that &#8220;1,320&#8221; on its own could not.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>An honest SEO forecast is not a number, it&#8217;s a distribution<\/strong>: it says how much we can expect <em>and<\/em> how wide the uncertainty around that expectation is. Bringing that width to the client&#8217;s table, instead of hiding it behind a round figure, is what separates a promise from a defensible estimate.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"simulatore\">The simulator: geometric Brownian motion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To make the concept even more tangible, we&#8217;ve built an <strong>interactive simulator<\/strong> that applies the Monte Carlo method to predict the future value of an investment. The underlying model is <strong>geometric Brownian motion<\/strong> (GBM), the same model used in the famous Black-Scholes framework for options pricing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Intuitively, an asset&#8217;s future price is computed as the current price multiplied by a random growth factor. The formula that generates one step of the path is:<\/p>\n\n\n\n\\( S_{t+1} = S_t \\cdot \\exp\\left( \\left(\\mu &#8211; \\frac{\\sigma^2}{2}\\right)\\Delta t + \\sigma \\sqrt{\\Delta t}\\; Z \\right) \\\\ \\)\n\n\n\n<p class=\"wp-block-paragraph\">where <strong>\u03bc<\/strong> is the expected annual return (the &#8220;average growth&#8221;), <strong>\u03c3<\/strong> is the volatility (how much the price fluctuates \u2014 our measure of uncertainty), <strong>\u0394t<\/strong> is the width of the time step, and <strong>Z<\/strong> is a random number drawn from a normal distribution. Each simulation generates a different path: some scenarios see the portfolio grow substantially, others see it decline.<\/p>\n\n\n\n<div class=\"wp-block-group has-background\" style=\"background-color:#f5f7f9;margin-top:2.5rem;margin-bottom:2.5rem;padding-top:1.5rem;padding-right:1.5rem;padding-bottom:1rem;padding-left:1.5rem\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-container-core-group-is-layout-eed7543b wp-block-group-is-layout-constrained\">\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1050\" height=\"660\" src=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-gbm-traiettorie-en.png\" alt=\"Simulated paths of an investment's value over one year: the 5th\u201395th percentile band widens over time while the median grows slowly.\" class=\"wp-image-4088\" srcset=\"https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-gbm-traiettorie-en.png 1050w, https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-gbm-traiettorie-en-300x189.png 300w, https:\/\/www.gironi.it\/blog\/wp-content\/uploads\/2026\/07\/montecarlo-gbm-traiettorie-en-1024x644.png 1024w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption class=\"wp-element-caption\">Simulated paths of an investment&#8217;s value over one year: the 5th\u201395th percentile band widens over time while the median grows slowly.<\/figcaption><\/figure>\n\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The chart above shows the fan of possible paths; the simulator below lets you turn the knobs \u2014 return, volatility, horizon \u2014 and watch how the distribution of final outcomes changes.<\/p>\n\n\n\n<iframe src=\"https:\/\/www.gironi.it\/utility\/montecarlo-simulator-en\/\" width=\"100%\" height=\"600\" style=\"border:none;border-radius:12px;\" loading=\"lazy\" title=\"Monte Carlo Simulator\"><\/iframe>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"applicazioni\">Where the Monte Carlo method is used today<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">From the nuclear physics of the 1940s, the Monte Carlo method has spread to domains that Ulam and von Neumann could never have imagined. Let&#8217;s look at some of the most fascinating applications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3D rendering and cinema.<\/strong> Every time we watch a Pixar film or a blockbuster with visual effects, we&#8217;re admiring Monte Carlo at work. The technique is called <strong>path tracing<\/strong>: to compute the color of each pixel, the software simulates millions of light rays bouncing between surfaces in the scene. Each ray follows a random path, and the average of thousands of paths produces the photorealistic image we see on screen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Finance and risk management.<\/strong> In the financial world, Monte Carlo is ubiquitous. Banks use it to calculate <strong>Value at Risk<\/strong> (VaR) \u2014 the maximum probable loss of a portfolio over a given time horizon. It&#8217;s the same principle as our simulator, applied to portfolios with hundreds of assets and complex correlations. Pricing exotic options that lack closed-form solutions also relies on Monte Carlo simulations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Drug discovery.<\/strong> In pharmaceutical research, Monte Carlo is used to simulate <strong>molecular docking<\/strong>: how a candidate molecule binds to a target protein. By simulating millions of possible spatial configurations, researchers identify the most promising compounds before synthesizing them in the lab, saving years of experimentation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Climate models.<\/strong> Models predicting climate change are inherently uncertain: they depend on emission scenarios, atmospheric feedback, ocean dynamics. Monte Carlo allows exploration of thousands of parameter combinations and generates the <strong>uncertainty bands<\/strong> we see in IPCC reports. Not a single prediction, but a distribution of possible futures.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Artificial intelligence.<\/strong> In machine learning, a technique called <strong>Monte Carlo dropout<\/strong> uses simulation to estimate the uncertainty of a neural network&#8217;s predictions. And the famous <strong>AlphaGo<\/strong> by DeepMind, which in 2016 defeated the world Go champion, used <strong>Monte Carlo Tree Search<\/strong> (MCTS) to explore possible moves in a game with more configurations than atoms in the universe.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Field<\/th><th>Example<\/th><th>What is simulated<\/th><\/tr><\/thead><tbody><tr><td>Cinema\/3D<\/td><td>Path tracing (Pixar)<\/td><td>Light ray paths<\/td><\/tr><tr><td>Finance<\/td><td>Value at Risk<\/td><td>Market scenarios<\/td><\/tr><tr><td>Pharmaceuticals<\/td><td>Molecular docking<\/td><td>Spatial configurations<\/td><\/tr><tr><td>Climate<\/td><td>IPCC models<\/td><td>Parameter combinations<\/td><\/tr><tr><td>AI<\/td><td>AlphaGo (MCTS)<\/td><td>Possible moves<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"limiti\">Advantages, limits and the caveat to remember<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Like any statistical tool, the Monte Carlo method has its strengths and limitations. Let&#8217;s examine them honestly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Flexibility.<\/strong> The greatest advantage is versatility: Monte Carlo applies to complex problems of any size and in any field, from finance to engineering, physics to biology. It doesn&#8217;t require closed-form solutions, only the ability to simulate the process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Accuracy.<\/strong> With a sufficient number of simulations, the estimate can be made arbitrarily precise. The more we run the method, the closer the result converges to the true value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Scalability.<\/strong> Unlike grid-based methods, which suffer from the &#8220;curse of dimensionality&#8221; (cost explodes with the number of variables), Monte Carlo maintains the same convergence rate regardless of the number of dimensions. This makes it the only practical tool for high-dimensional problems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, the method also presents <strong>significant limitations<\/strong>. The first is <strong>slow convergence<\/strong>: the 1\/\u221an rate means that gaining one digit of precision requires 100 times more simulations, and for problems demanding very high precision this can be prohibitive. The second is <strong>computational cost<\/strong>: for complex problems each individual simulation may require significant time, and multiplied by millions of iterations the bill becomes steep.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is, however, a more insidious limit, one that concerns not the computation but the reasoning:<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background wp-block-paragraph\">A word of warning: Monte Carlo does not create information out of nothing, it propagates it. The distribution of results is reliable exactly as much as the distributions we feed into the model. If we get the means, standard deviations or correlations of the inputs wrong, we&#8217;ll get an output that is precise in form but false in substance \u2014 the classic garbage in, garbage out. And the thousands of simulations lend an illusion of rigor that the underlying model may not deserve: the hard part isn&#8217;t running the code, it&#8217;s choosing the distributions well.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To mitigate the limits of cost and convergence, <strong>variance reduction techniques<\/strong> have been developed over the years, enabling more precise results with fewer simulations:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Importance sampling<\/strong>: sampling from an alternative distribution that &#8220;concentrates&#8221; simulations in the most informative regions.<\/li><li><strong>Control variates<\/strong>: using a correlated variable with known expected value to reduce the estimate&#8217;s variance.<\/li><li><strong>Stratified sampling<\/strong>: dividing the space into homogeneous subgroups and sampling from each.<\/li><li><strong>Antithetic variates<\/strong>: exploiting pairs of negatively correlated random numbers to reduce variance.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The Monte Carlo method represents one of the most powerful tools in computational statistics. In future articles, we&#8217;ll explore how some of these techniques \u2014 particularly the <strong>bootstrap<\/strong>, a close relative of Monte Carlo \u2014 apply to concrete problems in statistical inference.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Further reading<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For a deeper dive into the Monte Carlo method and its applications in finance, <a href=\"https:\/\/www.amazon.it\/dp\/1441915753?tag=consulenzeinf-21\" rel=\"nofollow sponsored noopener\" target=\"_blank\"><em>Monte Carlo Methods in Financial Engineering<\/em><\/a> by Paul Glasserman is the most comprehensive reference: it covers theory and practice with detailed examples in derivative pricing and risk management. For the more popular side \u2014 the idea that a good forecast is a distribution of scenarios rather than a single number \u2014 <a href=\"https:\/\/www.amazon.it\/dp\/0141975652?tag=consulenzeinf-21\" rel=\"nofollow sponsored noopener\" target=\"_blank\"><em>The Signal and the Noise<\/em><\/a> by Nate Silver is an excellent read on probabilistic reasoning applied to prediction.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is the Monte Carlo method The story of the Monte Carlo method begins in the most unlikely way: with a mathematician in bed playing cards. In 1946, Stanis\u0142aw Ulam, a Polish mathematician recovering from surgery, found himself playing solitaire to pass the time. Being a mathematician, he wondered: what are the chances of winning &hellip; <a href=\"https:\/\/www.gironi.it\/blog\/en\/the-monte-carlo-method-explained-simply-with-real-world-applications\/\" class=\"more-link\">Leggi tutto<span class=\"screen-reader-text\"> &#8220;The Monte Carlo Method Explained Simply with Real-World Applications&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[161],"tags":[],"class_list":["post-3512","post","type-post","status-publish","format-standard","hentry","category-statistics"],"lang":"en","translations":{"en":3512,"it":2983},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"Paolo Gironi","author_link":"https:\/\/www.gironi.it\/blog\/author\/autore-articoli\/"},"uagb_comment_info":0,"uagb_excerpt":"What is the Monte Carlo method The story of the Monte Carlo method begins in the most unlikely way: with a mathematician in bed playing cards. In 1946, Stanis\u0142aw Ulam, a Polish mathematician recovering from surgery, found himself playing solitaire to pass the time. Being a mathematician, he wondered: what are the chances of winning&hellip;","_links":{"self":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/comments?post=3512"}],"version-history":[{"count":5,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3512\/revisions"}],"predecessor-version":[{"id":4089,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/posts\/3512\/revisions\/4089"}],"wp:attachment":[{"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/media?parent=3512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/categories?post=3512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gironi.it\/blog\/wp-json\/wp\/v2\/tags?post=3512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}