This program simulate you game
sim=1000000
prob=matrix(data=0,nrow=13,ncol=1)
for(x in 1:13)
{
print(x)
for(iter in 1:sim)
{
#print(paste(iter/sim,x,sep=" "))
cards=1:13
cards=c(cards,cards,cards,cards,cards,cards,cards,cards,cards,cards,cards)# suppose to use more than one deck
cards=cards[-x]
y=-1
while(T)
{
y=sample(x=cards,size=1)
if(y!=x)
break
cards=cards[-which(cards==y)[1]]
}
if(x<y)
prob[x]=prob[x]+1
}
}
prob=prob/sim
rank=1:13
formula=(13-rank)/12 # your formula
#prob=vector(prob)
formula-prob #error between the estimated probability and your formula
formula-prob
[,1]
[1,] 0.000000e+00
[2,] 1.516667e-04
[3,] 8.533333e-05
[4,] 3.830000e-04
[5,] 7.036667e-04
[6,] 8.143333e-04
[7,] 1.070000e-04
[8,] -1.005333e-03
[9,] 7.083333e-04
[10,] -5.590000e-04
[11,] 3.986667e-04
[12,] 3.003333e-04
[13,] 0.000000e+00
>
The error is small so your formula it's probably right
Here's a Python program that I believe is correct. It takes a little under 7 minutes on my machine to run through every pair of hands.
from itertools import combinations
from collections import Counter
JACK, QUEEN, KING, ACE = 11, 12, 13, 14
N_HANDS = 22100 # 52 choose 3
deck = frozenset((rank, suit)
for rank in range(2, ACE + 1)
for suit in range(4))
assert len(deck) == 52
evaluate_hand_cache = {}
def evaluate_hand(hand):
if hand not in evaluate_hand_cache:
evaluate_hand_cache[hand] = evaluate_hand_(hand)
return evaluate_hand_cache[hand]
def evaluate_hand_(hand):
ranks = tuple(sorted((rank for (rank, _) in hand), reverse = True))
suits = [suit for (_, suit) in hand]
if ranks[0] == ranks[1] == ranks[2]:
# Three of a kind
return (5, ranks[0])
straight = (ranks[0] == ranks[1] + 1 == ranks[2] + 2
or ranks == (ACE, 3, 2))
flush = suits[0] == suits[1] == suits[2]
if straight and flush:
return (6, ranks[0])
if straight:
return (4, ranks[0])
if flush:
return (3,) + ranks
if ranks[0] == ranks[1]:
# Pair
return (2, ranks[0], ranks[2])
if ranks[1] == ranks[2]:
# Also a pair
return (2, ranks[2], ranks[0])
return (1,) + ranks
results = Counter()
divisor = N_HANDS // 100
for i, dealer_hand in enumerate(combinations(deck, 3)):
if i % divisor == 0:
print "{}% complete".format(i // divisor)
dealer_hand = frozenset(dealer_hand)
dealer_e = evaluate_hand(dealer_hand)
for player_hand in combinations(deck - dealer_hand, 3):
player_e = evaluate_hand(player_hand)
outcome = (
'Dealer does not qualify'
if dealer_e < (2, QUEEN) else
'Player loses'
if player_e < dealer_e else
'Player wins'
if dealer_e < player_e else
'Tie')
results[(player_e[0], outcome)] += 1
print "Player hand class,Outcome,Count"
for (hand, outcome), n in sorted(results.items()):
print ','.join([str(hand), outcome, str(n)])
The output is:
Player hand class,Outcome,Count
1,Dealer does not qualify,264851952
1,Player loses,38038608
2,Dealer does not qualify,60280560
2,Player loses,8453520
2,Player wins,242784
2,Tie,2592
3,Dealer does not qualify,17630040
3,Player loses,1260596
3,Player wins,1298780
3,Tie,3288
4,Dealer does not qualify,11581584
4,Player loses,267804
4,Player wins,1392204
4,Tie,23688
5,Dealer does not qualify,836520
5,Player loses,3312
5,Player wins,118216
6,Dealer does not qualify,771024
6,Player loses,956
6,Player wins,112204
6,Tie,168
Best Answer
In short, the probability of a 7-card straight when drawing 7 random cards from a standard deck of 52 is $0.000979$.
To calculate this value, we note that all 7-card hands are equally likely, of which there are ${52 \choose 7} = 133,784,560$ possibilities.
Next, we compute the number of 7-card straights. Ignoring suit, we note that there are $8$ possible straights (starting with {A, 2, 3, 4, 5, 6, 7} through {8, 9, 10, J, Q, K, A}). For each card in the straight, there are 4 possibilities for the suit, such that there are $4^7 = 16384$ ways to assign the suits to the 7 cards. However, $4$ of these suit assignments yield straight flushes (all clubs, all diamonds, etc.), so the actual number of suit assignments that can yield a straight (but not a straight flush) is $16384 - 4 = 16380$.
Putting all this together, there are $8 \times 16380 = 131,040$ possible 7-card straights out of $133,784,560$ possible 7-card hands, yielding a probability of $\approx 0.000979$.