Monte Carlo Simulations in Excel with Python

Опубликовано: 22 Март 2026
на канале: PyXLL - Write Excel Add-Ins with Python and Java
2,905
63

Monte Carlo style simulations in Excel using Python and PyXLL

All the code accompanying this video can be found here
https://github.com/pyxll/pyxll-exampl...

Learn how we can use Monte Carlo to calculate estimates to Excel models by using random distributions as input variables.

Python is used to generate random numbers from different distributions (the 3 point PERT distribution is used in this video) and the result of an Excel formula is collected for many samples of input variables using those distributions.

The input distributions and the sampled output distribution are displayed in Excel using the Python plotting package seaborn.

00:00 - Intro
00:36 - Example use case
01:17 - PyXLL
01:35 - Background explaination
02:11 - Writing a Python Excel macro
02:33 - The three point 'PERT' distribution
03:52 - Running the macro in Excel
04:18 - Writing the main Python code
06:08 - Plotting the input distributions
07:38 - The Monte Carlo simulation
12:40 - Improving the performance
15:41 - Extracting and plotting the results
17:46 - Making it reusable
18:58 - Wrapping up

Resources
========

PyXLL: https://www.pyxll.com
Source code: https://github.com/pyxll/pyxll-exampl...
pertdist: https://pypi.org/project/pertdist/
seaborn: https://seaborn.pydata.org/