library(tidyverse)
Ch3,Ex12:
A poker hand is a set of 5 cards randomly chosen from a deck of 52 cards. Find the probability of a:
- royal flush
- straight flush
JB:
First, I’ll create a function that’s shorter to type for factorial:
f <- function(n){
factorial(n)
}
a) Royal Flush:
First, I gotta find calculate the event space, that is, the number of possible 5-card hands from a deck of 52:
\(\binom{52}{5}=\frac{52!}{5!(52-5)!}=2,598,960\) posible 5-card hands.
all_hands <- f(52)/(f(5)*f(52-5))
Next, I determine the number of possible royal flushes is 4 based on the 4 suits.
\(\therefore\) the probability of getting a royal flush is: \(\frac{4}{2,598,960}=\)
## [1] 1.539077e-06
b) Straight Flush:
First, we determine the number of straight flushes excluding the royal flush:
If we focus on a single suit for the moment, and we take out the royal flush cards but keep in the ace because when it shows up in the royal, it only shows up as the high card, that leaves us with:
a, k, q, j, 10, 9, 8, 7, 6, 5, 4, 3, 2, a
Or 9 possible cards that compose the hand for a singlue suite. We then multiply this by 4 to capture all the possible straight flushes across the 4 different suits: \(9 \times 4 = 36\)
We then divide this number by the total number of hands possible within the deck (determined in the previous problem and saved as all_hands
).
\(\therefore\) the probability of getting a straight flush is: \(\frac{36}{2,598,960}=\)
## [1] 1.385169e-05