Hand Value Distribution — 7-Card and Partial-Hand Counting

# Hand Value Distribution — 7-Card and Partial-Hand Counting

For equity calculations and hand potential, we need to know how many n-card combinations produce each of the 7,462 distinct 5-card hand values.

---

## 7-Card Hand Distribution

For each 5-card hand rank R, count 7-card hands where R is the **best** 5-card sub-hand:

```
count(R) = C(47, 2) − Σ[hands where 2 extra cards create a hand better than R]
```

### Approximate Distribution

| Hand Type | 7-Card Count | Frequency |
|-----------|-------------|-----------|
| Royal Flush | 4,324 | 0.0032% |
| Straight Flush | 37,260 | 0.028% |
| Four of a Kind | 224,848 | 0.17% |
| Full House | 3,473,184 | 2.60% |
| Flush | 4,047,644 | 3.03% |
| Straight | 6,180,020 | 4.62% |
| Three of a Kind | 6,461,620 | 4.83% |
| Two Pair | 31,433,400 | 23.50% |
| One Pair | 58,627,800 | 43.82% |
| High Card | 23,294,460 | 17.41% |

### Computation Methods

1. **Combinatorial Enumeration** — For each of 7,462 hand values, count C(47,2) completions minus those creating better hands. Challenge: avoiding double-counting.

2. **Inclusion-Exclusion (hierarchical)** — Process best-to-worst. For each hand type, count completions and subtract already-counted better hands.

3. **Pattern Grouping** — Group isomorphic hands (e.g., all non-nut flushes of same strength) and compute once per pattern.

---

## Partial-Hand (1–6 Card) Cumulative Counts

For each rank R, count all n-card hands (n=1..6) that **contain a 5-card sub-hand of rank R as their best**:

```
Total(R) = Σ(n=1..6) count_ncard_hands_with_best_subhand(R)
```

### Method: Hierarchical from Best to Worst

```python
for rank in range(7462, 0, -1):  # best to worst
    hand = get_5card_hand(rank)
    for n in [6, 5, 4, 3, 2, 1]:
        for subset in combinations(hand, n):
            if no_better_completion_exists(subset, rank):
                total[rank] += 1
```

### Challenge: `no_better_completion_exists()`
For a partial hand (1–4 cards), check if any completion to 5 cards produces a better rank. This requires checking against all possible card fill-ins.

### Optimization: Precomputed Potential Tables
Group partial hands by pattern (suited pair, connected offsuit, etc.) and precompute the best possible 5-card hand each can become.

---

## Practical Recommendations

1. Start with 5-card and 6-card counts (most straightforward)
2. Use hand pattern grouping to reduce computation
3. Build partial-hand counts incrementally
4. Memoize results for common patterns

---

## Relevance to super-marvin

These distributions feed into `HandPotential` calculations — knowing how many opponent hands beat us at each rank level is core to ppot/npot computation. The `HandPotential` module enumerates opponent hands and future board cards; efficient counting directly improves simulation performance.

id: 41b23b8d89e44449a6f44c8868cfa307
parent_id: 1246bbc3bb4948fc8329079b84b4ae3d
created_time: 2026-05-31T10:59:27.908Z
updated_time: 2026-05-31T10:59:27.908Z
is_conflict: 0
latitude: 0.00000000
longitude: 0.00000000
altitude: 0.0000
author: 
source_url: 
is_todo: 0
todo_due: 0
todo_completed: 0
source: joplin-desktop
source_application: net.cozic.joplin-desktop
application_data: 
order: 1780225167908
user_created_time: 2026-05-31T10:59:27.908Z
user_updated_time: 2026-05-31T10:59:27.908Z
encryption_cipher_text: 
encryption_applied: 0
markup_language: 1
is_shared: 0
share_id: 
conflict_original_id: 
master_key_id: 
user_data: 
deleted_time: 0
type_: 1