PyData NYC 2022

Simulations in Python: Discrete Event Simulation with SimPy
11-09, 16:15–17:00 (America/New_York), Central Park West (6th floor)

Add to your machine learning arsenal with an introduction to simulation in Python using SimPy! Simulations are increasingly important in machine learning, with applications that include simulating the spread of COVID-19 to make decisions about public policy, vaccination and shutdowns.

You can use simulation to answer questions like, Can you increase profits by adding more tables or staff to your restaurant? You can also use simulation to create data for modeling when it's hard or impossible to get (e.g. simulate purchases in response to promotions on certain products to see if they increase sales).

To benefit from this talk, you'll need to know a small amount of Python, specifically how to write functions and simple classes. No previous knowledge of simulation needed! If you know about simulation in another language and want to see a SimPy example, you can also benefit from this talk. You'll get a Jupyter notebook with a simple but fully worked out example to follow along with and to study on your own time after the conference.


Discrete event simulation (DES) allows you to study the behavior of a process or system over time. Simulations are used to study the effects of process changes (e.g. what happens to wait times if you increase/decrease the number of call center agents working at a given time) and to create data for modeling when it's hard or impossible to get (e.g. simulate purchases in response to promotions on certain products to see if they increase sales).

In this talk, you'll be quickly and efficiently introduced to the basics of simulation through a simple but fully worked out example in SimPy, a popular package for DES in Python. You'll learn about event handling and the priority queue. You'll be able to run a simulation and record metrics like wait times to enable the improvement of real-life processes.

To get the most out of the talk, you should be comfortable with writing basic code in a Jupyter notebook environment. This includes knowing how to write functions and (basic) classes. If you're not super comfortable with writing classes, you can still follow along with most of the simulation logic and can then study the worked out example on your own later.

We'll spend about 10 minutes getting up to speed with discrete event simulation using a mocked up non-code example. Here we'll introduce concepts like entities, resources, events, states and queues.

We'll then spend 25 minutes working through an already written SimPy example. We'll introduce SimPy concepts such as the priority queue and event handling. Being already familiar with Python concepts like functions, classes and instantiating objects from user-defined classes will make the code easier to follow (instantiating objects just means creating a new object of the type of your handmade class). You'll get a link to a Jupyter notebook with the code that you can either download from GitHub or run on Google Colab.


Prior Knowledge Expected

Previous knowledge expected

Lara is a data scientist (but who isn't these days), curriculum developer and instructor. She's a data science manager at Ernst & Young (EY) and an adjunct at the University of Chicago's Booth School of Business. When she's not writing Python code, she's probably taking care of foster kittens or falling on the ice (thanks to a recent but so far not-very-successful attempt to learn to figure skate).