# Monte Carlo method Monte Carlo methods solve deterministic or stochastic problems by repeated random sampling, transforming uncertainty into numerical estimates of integrals, optima, or distributions. Law-of-large-numbers convergence, importance sampling, MCMC, and particle filters enable [[Simulation|simulation]] of high-dimensional or analytically intractable systems. <!-- LEGACYSIM:BEGIN v1.5 — generated by g03_mint_wave.py; three.js first; do not hand-edit inside --> ## Microsims (promoted from legacy — three.js first) ### Microsim (three.js) <div class="microsim-player"> <!-- MICROSIM:PENDING_DEPLOY:BEGIN v1.7 g08 — embed target is not on the CDN; restore with g08 --undeploy-clear --> <p class="wt-pending"><strong>Microsim staged, not yet on the CDN.</strong> <code>Monte_Carlo_method.html</code> is built and deploy-ready in <code>Microsims for Dissemination/</code>, but the Netlify project still serves the geometry+spintronics set only. The player is disabled until the deploy lands; the explanatory text below is unchanged.</p> <!-- <iframe src="https://wikitube-3d-microsims.netlify.app/Monte_Carlo_method.html" width="100%" height="620" frameborder="0" loading="lazy" sandbox="allow-scripts allow-same-origin"></iframe> --> <!-- MICROSIM:PENDING_DEPLOY:END --> </div> *A cornerstone randomized algorithm, the Monte Carlo method turns an [[Expected_value|expected value]] into something you can measure by counting random samples — the same trick behind [[Reinforcement_learning]] rollouts and [[Graphics_processing_unit|GPU]] path tracing.* > The Monte Carlo method estimates a number by taking random samples and counting outcomes, rather than solving equations exactly. This microsim scatters random points inside a cube that encloses a unit sphere; the fraction landing inside the sphere is proportional to π. Pressing **Play** streams in samples so you can watch the running estimate wobble toward 3.14159, while **Reset** starts a fresh random run. It makes the law of large numbers visible: more samples, less noise — but only slowly. ### About this microsim The canvas shows a cube enclosing an inscribed unit sphere while random points rain into it, each colored by whether it landed inside the sphere ($x^2+y^2+z^2\le 1$) or outside; a live counter turns the running tally into an estimate of π. **Play** starts the sampling stream, **Pause** freezes it so you can read the current estimate, and **Reset** clears the tally for a new independent run. The **speedSlider (1–200)** sets how many points drop per frame: keep it low to watch single samples make the estimate lurch, then push it toward 200 to pour in thousands and watch it settle. Reset and replay at the same speed and no two runs trace the same path — the show-before-tell payoff is feeling randomness average out toward a fixed answer. ### Related microsims - [[Expected_value]] — the estimate is a sample mean converging to an expected value, the theoretical backbone of every Monte Carlo run. - [[Reinforcement_learning]] — Monte Carlo value estimation averages sampled returns exactly as this sim averages sphere hits. - [[Graphics_processing_unit]] — path-traced rendering is massively parallel Monte Carlo integration of light. - [[Polytope]] — the enclosing cube is the polytope whose volume normalizes the sphere-hit ratio into π. - Floating-point arithmetic — every random coordinate and inside-test is computed in finite-precision floating point. - [[Dynamic_programming]] — a deterministic contrast: exact table-filling where Monte Carlo instead samples. - [[Combinatorial_optimization]] — related ALGORITHM microsim - Dopamine — related ALGORITHM microsim - Extreme value theorem — related ALGORITHM microsim - Model predictive control — related ALGORITHM microsim - [[Optimal_control]] — related ALGORITHM microsim - Process optimization — related ALGORITHM microsim <!-- LEGACYSIM:END --> <!-- GIFPLATE:BEGIN v1.0 g16 — Commons hotlink; do not hand-edit inside --> ## Images <figure class="wt-gifplate"> <img src="https://commons.wikimedia.org/wiki/Special:FilePath/Pi_monte_carlo_all.gif" alt="Convergence to Pi" loading="lazy" decoding="async"> <figcaption><strong>Convergence to Pi</strong> — Watch random samples converge to the true value of π.<br> <span class="wt-credit">Wikimedia Commons &middot; <strong>licence pending verification</strong> (run <code>g17_gif_verify.py</code> on a networked lane) &middot; <a href="https://commons.wikimedia.org/wiki/File:Pi_monte_carlo_all.gif">Details</a></span></figcaption> </figure> *The hub concept of [[PORTAL_Monte_Carlo_method]], and this page has no interactive build yet — the plate carries it.* <!-- GIFPLATE:END --> ## Reveal %%REVEAL:p5%% %%REVEAL:d3%% --- *Concept aligned with [Wikipedia](https://en.wikipedia.org/wiki/Monte_Carlo_method); adapted text, where present, is licensed [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/).* ## Overview Born at Los Alamos with [[John_von_Neumann|John von Neumann]] and colleagues, the method rests on [[Probability|probability]]: draw from a [[Probability_distribution|probability distribution]], average, and let the [[Central_limit_theorem|central limit theorem]] price the error around the [[Expected_value|expected value]]. [[Bayesian_inference|Bayesian inference]] leans on it wherever a [[Prior_probability|prior]] meets an intractable posterior, and [[Statistical_inference|statistical inference]] at large uses it to calibrate [[Uncertainty|uncertainty]] and [[Risk|risk]]. Applications blanket [[Statistical_mechanics|statistical mechanics]] and [[Computational_physics|computational physics]], [[Mathematical_optimization|optimization]] and the [[Genetic_algorithm|genetic algorithm]], [[Bioinformatics|bioinformatics]] and [[Computational_biology|computational biology]], [[Signal_processing|signal processing]], [[Econometrics|econometrics]], [[Project_management|project-management]] risk, [[Reliability_engineering|reliability engineering]], rendering in the [[Video_game|video game]], and validation of any [[Deterministic_system|deterministic system]] too tangled for closed form — all riding a good [[Algorithm|algorithm]] within [[Operations_research|operations research]]. <!-- CRAFT-LINK:START g12 --> *Built to the [[WT!Three_js_Microsim_Master_Class|three.js Master Class]].* <!-- CRAFT-LINK:END --> ## Wikipedia : Wikitube **Strict pair:** [Wikipedia](https://en.wikipedia.org/wiki/Monte_Carlo_method) : [Wikitube](https://en.wikitube.io/wiki/Monte_Carlo_method) ## Previous hub tags Hubs: `ALGORITHM`, `Systems`. Portals: [[PORTAL_Systems]], [[PORTAL_Monte_Carlo_method]].