Which Bootcamp is Right for Your Career Goals? Explore Programs

What is a Monte Carlo Simulation? (Part 4)

By Zachariah Miller • February 23, 2018

This is part 4 of a series written by Metis Sr. Data Scientist Zach Miller dedicated to investigating how Monte Carlo can be a great tool. Part 1 introduces the concept of Monte Carlo, Part 2 teaches us how to do MC in Python, and Part 3 explores how we can use it to (attempt to) outplay the odds in video poker. If you haven't read those yet, start there. The final installment, Part 5, is coming soon.

How do physicists use Monte Carlo to simulate particle interactions?

Understanding how particles behave is hard. Really hard. "Dedicate your whole life just to figure how often neutrons scatter off of protons when they're going at this speed, but then slowly realizing that question is still too complicated and I can't answer it despite spending the last 30 years trying, so what if I just figure out how neutrons behave when I shoot them at objects rich with protons and then try to figure out what they're doing there and work backward to what the behavior would be if the protons weren't currently bonded with lithium. Oh, SCREW IT I've got tenure so I'm just going to teach and write books about how terrible neutrons are..." hard.

Due to this challenge, physicists almost always need to design experiments with extreme care. To do that, they need to be able to simulate what they expect will happen when they set up their experiments so that they don't waste a bunch of time, money, and effort only to find out that their experiment is designed in a way that has no chance of working. The tool of choice to make sure the experiments have a chance at success is Monte Carlo. Physicists will design the experiments entirely in the simulation, then shoot particles into their detectors and see what happens based on what we currently know. This gives them a reasonable idea of what's going to happen in the experiment. Then they can design the experiment, run it, and see if it agrees with how we currently understand the world. It's a really cool system of using Monte Carlo to make sure that science is efficient.

A few programs that nuclear and particle physicists tend to use often are GEANT and Pythia. These are magnificent tools that have gigantic teams of people managing them and updating them. They're also so complicated that it's borderline uninstructive to look into how they work. To remedy that, we're going to build our own, much much much (much1,000,000) simpler, version of GEANT. We'll only work in 1-dimension for now.

So before we get started, let's break down what the goal is (see next paragraph if the particle talk throws you off): we want to be able to create some block of material, then shoot a particle into it. The particle will move through the material and have a random chance of bouncing in the material. If it bounces it loses speed. Our ultimate goal is to figure out: based on the starting speed of the particle, how likely is it that it can get through the material? We'll then get more complicated and say, "what if there were two different materials stacked back to back?"

For those who think, "whoa, what's with the particle stuff, can you give me a metaphor that is more easy to understand?" Yes. Yes, I can. Imagine that you're shooting a bullet into a block of "bullet stopping material." Depending on how strong the material is, the bullet may or may not actually be stopped. We can model that bullet-protection-strength by using random numbers to decide if the bullet slows down after each step if we assume we can break its motion into tiny steps. We want to measure, how likely is it that the bullet makes it through the block. So in the physics parlance: the bullet is the particle, and the material is the block. Without further adieu, here is the Particle Simulator Monte Carlo Notebook. There are lots of comments and text blurbs to explain the methodology and why we're making the choices we do. Enjoy!

So what did we learn?

We've learned how to simulate basic particle interactions by giving a particle some velocity and then moving it through a space. We then added the ability to create blocks of material with different properties that define them, and stack those blocks together to form an entire surface. We combined those two ideas and used Monte Carlo to test whether particles can make it through blocks of material or not - and discovered that it really depends on the initial speed of the particle. We also found out that the way that the speed is linked to survival isn't very intuitive! It's not just a straight line or an "on-off" step-function. Instead, it's a slightly weird "turn-on-slowly" shape that changes based on the material present! This approximates really closely how physicists approach just these types of questions!

If you haven't already, read Part 1, Part 2, and Part 3 of Zach's series. 

Similar Posts

data science
Made at Metis: An Album Discovery Tool & A Voting Recommendation Engine

By Carlos Russo • September 25, 2020

This post features two projects from recent graduates of our data science bootcamp. Take a look at what's possible to create in just 12 weeks.

data science
Data Scientist Roundup: Python for Data Science, AI in Banking, & More

By Carlos Russo • October 01, 2020

When our Data Scientists aren't teaching the intensive 12-week bootcamps or corporate training courses, they're working on a variety of other projects. This monthly blog series tracks and discusses some of their recent activities and accomplishments.

data science
Reduced Tuition on Remaining 2020 Bootcamp Prep Courses

By Carlos Russo • September 08, 2020

From today through October 9th, when you enroll in any of our remaining 2020 Bootcamp Prep Courses, you'll save 33% on tuition. We hope this reduced tuition provides opportunities for those interested in building data science skills in a live online format, taught by industry leaders.