Skip to main content
Probability Cards
Menu

How the numbers are produced

Every figure on this site comes from one of two sources: exact counting or seeded simulation. This page documents both, their assumptions and their limits.

1. The deck model

A standard deck has 52 distinct cards: 13 ranks (A, 2–10, J, Q, K) in each of 4 suits. Each card has an integer id from 0 to 51, id = suit × 13 + (rank − 1). All selections are validated: ids must be integers from 0 to 51, no card may appear twice and the selection size is limited. The interface prevents duplicates and the engine rejects them if they ever arrive.

2. Exact combinatorics

Factorials, permutations P(n, k) = n!/(n−k)! and combinations C(n, k) = n!/(k!(n−k)!) use arbitrary-precision integers (BigInt), so there is no rounding until a final probability is converted to a decimal.

The nine five-card pattern counts come from closed-form counting arguments:

PatternCounting argumentCount
Straight flush10 rank runs × 4 suits40
Four of a kind13 ranks × 48 other cards624
Full house13·C(4,3) × 12·C(4,2)3,744
Flush(C(13,5) − 10) × 45,108
Straight10 × (4⁵ − 4)10,200
Three of a kind13·C(4,3) × C(12,2) × 4²54,912
Two pairC(13,2)·C(4,2)² × 11 × 4123,552
One pair13·C(4,2) × C(12,3) × 4³1,098,240
No pattern(C(13,5) − 10) × (4⁵ − 4)1,302,540

The ace counts as high or low in a run (A-2-3-4-5 and 10-J-Q-K-A), but runs do not wrap around (Q-K-A-2-3 is not a run). These nine categories partition all 2,598,960 combinations.

3. Random numbers and seeds

Randomness comes from mulberry32, a small, fast, well-tested 32-bit pseudo-random generator. A text seed is hashed to a 32-bit integer with an xmur3-style hash. Each simulator mixes its own name into the seed, so “lab-001” gives different but still reproducible streams in different tools. The same seed, settings and software version always produce identical results.

Cards are drawn with a (partial) Fisher–Yates shuffle, which makes every ordered selection equally likely when the underlying random numbers are uniform. The generator is not cryptographically secure and must not be used for security purposes. A fresh seed is created only when you press “New seed”, using the browser's crypto.getRandomValues where available.

4. Monte Carlo simulation

  1. Five-card pattern frequencies. For N samples, draw 5 distinct cards, classify the pattern and count. Observed probability = count ÷ N.
  2. Target cards in a draw. Draw n cards, count how many belong to the chosen target set. Compare the histogram, mean and variance with the hypergeometric distribution.
  3. Sampling variability. Repeat a whole experiment R times, each with m draws; each yields an estimate of P(at least one target). The spread of the R estimates is compared with √(p(1−p)/m).

Convergence charts record the running estimate at about 60 log-spaced sample counts. Sample sizes offered are 100, 1,000, 10,000 and 100,000; the engine accepts up to 1,000,000 but the interface limits itself to keep pages responsive.

5. Statistical summaries

6. Verification

The project includes automated unit tests that run on every build. Among other checks they:

7. Limitations

8. Reporting errors

If you find a mistake in the mathematics, please tell us through the contact page. Corrections to the counts or formulas should be accompanied by a reference or a short derivation.