liveBook · Manning

Monte Carlo simulation

Monte Carlo simulation is a computational technique that uses repeated random sampling to estimate quantities or characterize possible outcomes.

How 8 Manning books explain it

Statistics Every Programmer Needs

A Monte Carlo simulation estimates quantities or evaluates outcomes by repeatedly sampling from specified probability distributions or stochastic processes.

How it is used
Models uncertain outcomes to inform staffing and investment-risk decisions.
How deep it goes
Develops a six-step discrete workflow and a historical-return-based continuous workflow, including sampling and interpretation.
Examples
Uses Poisson-modeled call-center absenteeism and historical stock prices as discrete and continuous examples.
What you can do after
Build it from scratch in Python, then compare simulated frequencies and decision tradeoffs.

Read how Statistics Every Programmer Needs explains Monte Carlo simulation →

Build a Robo-Advisor with Python (From Scratch)

A Monte Carlo simulation is a computational technique that estimates outcomes by repeatedly sampling from specified probability distributions or scenarios.

How it is used
Estimates retirement funding risk and tax-strategy savings under individual financial circumstances.
How deep it goes
Builds an annual wealth-path implementation, then extends modeling to inflation, fat tails, bootstrapping, and mortality.
Examples
Uses a $100,000 return-order comparison and a $1.2 million, 30-year retirement simulation.
What you can do after
Apply it via Python and NumPy to generate wealth paths and estimate retirement bankruptcy probabilities.

Read how Build a Robo-Advisor with Python (From Scratch) explains Monte Carlo simulation →

Investing for Programmers

A Monte Carlo simulation is a computational technique that uses repeated random sampling to estimate outcomes or explore possible solutions.

How it is used
Measures Value at Risk and explores portfolio outcomes under uncertain future returns.
How deep it goes
Explains sampling inputs, simulated outcomes, percentiles, and portfolio selection, but stops short of modeling Black Swan events.
Examples
Uses Apple price simulations, 95% VaR, 10,000 random portfolios, efficient-frontier plots, and portfolio weights.
What you can do after
Build it from scratch to estimate stock VaR or compare randomly generated portfolios using historical returns.

Read how Investing for Programmers explains Monte Carlo simulation →

Causal AI

A Monte Carlo method is a randomized computational technique that estimates quantities by repeatedly sampling from a probability distribution.

How it is used
Estimates expectations, probabilities, and conditional quantities from probabilistic generative models.
How deep it goes
Defines sampling and averaging, demonstrates Python implementations, and stops short of detailed inference algorithms.
Examples
Uses indicator averages, squared samples, pgmpy data frames, and Pyro Gamma–Poisson–Bernoulli processes.
What you can do after
Apply it via Pyro or pgmpy to estimate expectations and probabilities from generated samples.

Read how Causal AI explains Monte Carlo simulation →

Machine Learning Algorithms in Depth

Monte Carlo sampling is a stochastic technique that uses random samples or simulated paths to estimate properties of uncertain quantities.

How it is used
Estimates uncertainty in simulated stock prices, random walks, and broader sampling-based inference procedures.
How deep it goes
Derives transition sampling and outcome computation, implements two simulations, and briefly situates scalable Monte Carlo variants without developing them.
Examples
Uses binomial stock-price paths and weighted self-avoiding walks on a two-dimensional grid.
What you can do after
Builds simulations from scratch, computes terminal outcomes, and evaluates uncertainty through repeated trials and plots.

Read how Machine Learning Algorithms in Depth explains Monte Carlo simulation →

Reinforcement Learning from Human Feedback

Monte Carlo estimation approximates an expectation or other quantity by averaging values from samples drawn from the relevant distribution.

How it is used
Approximates policy gradients, value targets, group advantages, and KL penalties from sampled language-model rollouts.
How deep it goes
Details sampling pipelines and backward return computation, but does not develop general convergence or variance analysis.
Examples
Uses sampled completions, token log-probabilities, on-policy returns, critic targets, and multiple responses to one prompt.
What you can do after
Apply it via sampled rollouts to estimate KL terms, policy gradients, value targets, or relative advantages in RL training.

Read how Reinforcement Learning from Human Feedback explains Monte Carlo simulation →

Grokking Statistics

A Monte Carlo simulation is a computational simulation method that models uncertain real-world processes by repeatedly generating random outcomes from probability distributions.

How it is used
Models uncertain real-world processes when direct data collection is difficult.
How deep it goes
Explains distribution choice and demonstrates two implementations, but defers more ambitious multi-component models.
Examples
Uses a coffee-shop barista, espresso-shot counts, and delivery timelines as its central example.
What you can do after
Build it from scratch with NumPy random generators to estimate totals and event timelines.

Read how Grokking Statistics explains Monte Carlo simulation →

Advanced Algorithms and Data Structures

A Monte Carlo algorithm is a randomized algorithm that permits a bounded probability of an incorrect result in exchange for controlled resource usage.

How it is used
Frames randomization as a way to control resources while accepting uncertainty, then applies it to k-means initialization.
How deep it goes
Defines the randomized distinction and works through k-means initialization, iteration, failure mode, and restart strategy.
Examples
Uses Bloom-filter false positives and k-means centroid initialization, clustering iterations, unlucky starts, and random restarts.
What you can do after
Apply it via random initialization and repeated restarts when deterministic processing depends strongly on the starting state.

Read how Advanced Algorithms and Data Structures explains Monte Carlo simulation →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.