Poker#

We are interested in the distribution of the sum of 3 random cards drawn from a shuffled deck.

Where Ace = 14, and J, Q, K = 11, 12, 13 respectively.

import numpy as np

card_values = [14, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

deck = card_values * 4

num_simulations = 10**6

draws = np.random.choice(deck, size=(num_simulations, 3), replace=True)

sum_of_draws = np.sum(draws, axis=1)

expected_value = np.mean(sum_of_draws)
variance = np.var(sum_of_draws)

expected_value, variance
(23.999912, 42.052581992256016)

Idea:

Note for Xi ~ Unif(a,a+1,…,b), E(Xi) = (a+b)/2, var(Xi) = 1/12*((b-a)^2 + 2(b-a))

Each Xi ~ Unif(2, 3, …, 14)

E(Xi) = 8

Var(Xi) = (12^2 + 2*12) / 12 = 14

Let S = X1 + X2 + X3, it follows that

E(S) = 24, var(S) = 42

Our assumption is that each draw is independent of the others (in reality it’s not, but we assume we are drawing from a population large enough, just to simplify calculations)

13 cards pulled, p(no ace)?#

\[ \frac{\binom{48}{13}}{\binom{52}{13}} = 0.3038 \]

0.3

import random

def simulate_no_ace_prob(trials):
    # Deck representation: 4 Aces (1) and 48 Non-Aces (0)
    deck = [1] * 4 + [0] * 48
    
    favorable_trials = 0
    draw_size = 13
    
    for _ in range(trials):
        drawn_cards = random.sample(deck, draw_size)
        
        if sum(drawn_cards) == 0:
            favorable_trials += 1
            
    simulated_probability = favorable_trials / trials
    return simulated_probability

# Run the simulation
num_trials = 100000
simulated_p = simulate_no_ace_prob(num_trials)

simulated_p
0.30283

three cards pulled from deck of 52, P(three num each differ from each other by at least 2)?#

0.478

Intuition: assume first card is in the middle, second card cannot be first card, first card +1 or first card -1, so left with 10 choices. Third card left with 7 choices. 1 * 10/13 * 7/13 = 0.41. True ans should be slightly bigger than this, since if first card is at the corner, then later cards are more likely to meet the condition of differing more than 2

import random

ranks = list(range(1, 14))  # 1=Ace, ..., 13=King
deck = [(r, s) for r in ranks for s in range(4)]

def trial():
    cards = random.sample(deck, 3)
    rs = sorted(c[0] for c in cards)
    return (rs[1] - rs[0] >= 2) and (rs[2] - rs[1] >= 2)

N = 1_000_000
sum(trial() for _ in range(N)) / N
0.477959