Estimate Probabilities of Card Games
A practical example of how you can calculate Card Probabilities with Monte Carlo Simulation and Numerically
Published in
5 min readAug 25, 2020
We are going to show how we can estimate card probabilities by applying Monte Carlo Simulation and how we can solve them numerically in Python. The first thing that we need to do is to create a deck of 52 cards.
How to Generate a Deck of Cards
import itertools, random# make a deck of cards
deck = list(itertools.product(['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'],['Spade','Heart','Diamond','Club']))deck
And we get:
[('A', 'Spade'),
('A', 'Heart'),
('A', 'Diamond'),
('A', 'Club'),
('2', 'Spade'),
('2', 'Heart'),
('2', 'Diamond'),
('2', 'Club'),
('3', 'Spade'),
('3', 'Heart'),
('3', 'Diamond'),
('3', 'Club'),
('4', 'Spade'),
('4', 'Heart'),
('4', 'Diamond'),
('4', 'Club'),
('5', 'Spade'),
('5', 'Heart'),
...
How to Shuffle the Deck
# shuffle the cards
random.shuffle(deck)
deck[0:10]
And we get:
[('6', 'Club'),
('8', 'Spade'),
('J', 'Heart'),
('10', 'Heart'),
('Q', 'Spade'),
('7', 'Diamond'),
('K', 'Diamond')…