Estimating Poker Hands

Let’s calculate a few poker probabilities for the 5-card hands. We employ basic calculations and some simulations.

5 hands from 52 cards

First, what is the total number of ways of getting five cards from a deck of 52? Is that a permutation or a combination? The fundamental question to ask is whether the order matters or not. The order of cards doesn’t matter here; hence we use combinations to get the required value.

_{52}C_5 = \frac{52!}{(52-5)!5!} = \frac{52!}{47!5!} =  2,598,956

Royal flush

This one comes first in the order and has a sequence of 10, J, Q, K, A, of a given suit.

poker, casino, games-2015890.jpg

The calculation is simple: Getting this combination out of five cards is 5C5 = 1. Since there are four types (suits), clubs, diamonds, spades and hearts, the total number becomes 4. The required probability of getting a royal flush is (4/2,598,956) = 0.00000154. Let’s do the simulation

First, create the deck

suits <- c("Diamonds", "Spades", "Hearts", "Clubs")
numbers <- c("Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King")
deck <- expand.grid(Number = numbers, Suit = suits)
deck <- paste(deck$Number, deck$Suit)

Then we write the following code to simulate the chances of getting a royal flush.

roy <- c("Ace", "Ten", "Jack", "Queen", "King")
royal <- expand.grid(Roy = roy, Suit = suits)
royal <- paste(royal$Roy, royal$Suit)

itr <- 10000000

poker <- replicate(itr,{
   shuffle <- sample(deck, 5)
      for (rep_trial in 1:4) {
          if(all(shuffle %in% royal[(5*rep_trial-4):(5*rep_trial)])==TRUE){
             counter <- 1
             break
          }else{
             counter = 0
         }
      }
     counter <- counter
})
mean(poker)

After running 10 million times, we get 12 occurrences and therefore, the probability is 0.0000012