Starts Monday: Beginner Python & Math Live Online Course. Enroll Now

What is a Monte Carlo Simulation? (Part 3)

By Zachariah Miller • February 12, 2018

This is part 3 of a series 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, and in part 2, he goes over how to implement it using Python.
_____

Can you beat the casino in video poker?

Spoiler alert: No, you can't. If you could, the games wouldn't be in the casino. However, meta logic aside, how definite is it that the casino will always beat you? We're going to use Monte Carlo to explore that concept. The methodology will go a little bit like this: build out a Python representation of a card deck, then use MC methodology to determine the best possible play you can make given your hand, then make that play and track your money over time.

The MC part will come into play when we select which cards to hold in the game. (If you aren't familiar with video poker, try checking this out.) We'll see what cards we have, then simulate the results of choosing to hold the cards and see what method gives us the best possible payout. Since this is a lot of work, I've put together a fairly long notebook that shows you all the code it takes to build a card deck, set up the poker game (we have to do the hand scoring), and then actually run the Monte Carlo simulations to see what happens. Throughout the Video Poker Monte Carlo Notebook there are lots of comments and text blurbs to explain the methodology.

So what did we learn?

As you can see from the notebook, even if you play poker perfectly by always making the move that gives you the best-expected return, the casino pretty much always comes out on top if you play long enough. We built out some pretty nifty machinery to be able to let Python play cards with itself over and over to figure what that best move is and it's still all for naught. However, along the way we've learned about using combinations of cards, multiple randomized simulations, and expected returns to make better choices. We also see that by playing smartly, we can WAY outperform playing randomly. In our next installment, we'll investigate how we can use these same principles to figure out how particles interact with matter by building our own particle simulation package in Python (coming soon)!

_____

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


Similar Posts

data science
Made at Metis: Recommendation Systems for Making Meals + Choosing Beer

By Emily Wilson • July 08, 2019

This post features two final projects from recent graduates of our data science bootcamp. Take a look at what's possible to create in just 12 weeks, including a meal recommendation app based on the produce you have at home + a recommendation engine to help you choose your next favorite beer.

data science
Event Recap: Q&As with Metis Program Managers in Chicago & NYC

By Metis • August 30, 2019

We recently hosted two related live online Ask Me Anything sessions on our Community Slack Channel. The first was with Caroline Csernus, Bootcamp Program Manager in Chicago, and the second was with Jesel Roosevelt, Bootcamp Program Manager in NYC. Each answered questions about the overall Data Science Bootcamp experience, plus some specific questions pertaining to how things run at each location. Read highlights here.

data science
3 Ways to Improve Your Data Science Communication Skills

By Lara Kattan • August 10, 2019

Data scientists are often described as hybrids: part statistician, part computer scientist; part analyst, part strategist. But while we focus on the myriad technical skills that a data scientist should possess, we often overlook one of the foundational skills (without which the whole edifice falls apart): communication skills. In this post, read three tips for improving your professional communication skills.