Get the latest tech news

When to Write a Simulator (2021)


To Write a Simulator My rule for when to write a simulator: Simulate anything that involves more than one probability, probabilities over time, or queues. Anything involving probability and/or queues you will need to approach with humility and care, as they are often deceivingly difficult: How many people with their random, erratic behaviour can you let into the checkout at once to make sure it doesn’t topple over? How many connections should you allow open to a database when it’s overloaded? What is the best algorithm to prioritize asynchronous jobs to uphold our SLOs as much as possible? If you’re in a meeting discussing whether to do algorithm X or Y with this nature of problem without a simulator (or amazing data), you’re wasting your time.

When I used to do informatics competitions in high school, I was never confident in my correctness of the more math-heavy tasks — so I would often write simulations for various things to make sure some condition held in a bunch of scenarios (often using binary search). It didn’t take long before some were pulling out complicated Wikipedia entries on probability theory, trawling their email for old student MatLab licenses, and formulas soon appeared on the whiteboard I had no idea how to parse. It won’t be long before someone points out deep learning is perfect, or some resemblance to protein folding or whatever… Write a simple simulation with a few different sizes and see if you can beat random by even a little bit.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Write a Simulator

Write a Simulator