Chris Collins

Tools · math

Probability: dice, cards, Bayes

Exact dice distributions with a chart; exact permutations and combinations; poker and lottery odds; the birthday problem; binomial, hypergeometric, geometric, and Poisson; Bayes with a natural-frequency tree and icon array; Bloom filters; a naive-Bayes spam filter; series/parallel reliability; expected value and Monte Carlo.

Added · updated 14 October 2026

Works with

How to use it

⛶ Full screen (or F) gives the open tab’s chart — the dice, birthday or binomial bars, the Bloom-filter curve or the reliability block diagram — the whole screen: the browser’s full screen where it is allowed, otherwise a full-window layer (iPhone). It is redrawn as the window changes, and the inputs stay above it. Escape leaves.

  • Dice — standard notation: 3d6, 1d20+5, 2d6-1d4, 4d6dl1 (drop lowest), 2d20kh1 (advantage), 2d20kl1 (disadvantage), d%, and Fudge dice 4dF. The distribution is exact: each term’s outcomes are convolved, and keep/drop dice are tracked through their kept values. Set a target to see P(total ≥ target).

  • Combinations — nCr, nPr, with repetition (nʳ), and multisets, computed exactly with arbitrary-size integers.

  • Cards and lottery — five-card poker hand frequencies out of C(52,5) = 2 598 960; a lottery’s odds for each number of matches, C(k,m)·C(n−k,k−m)/C(n,k); and the hypergeometric distribution for draws without replacement.

  • Birthday problem — P(shared) = 1 − Π(d − i)/d. With 365 days, 23 people give 50.7 %. Change the days to estimate hash or ID collisions.

  • Distributions — binomial, geometric (trials until the first success), and Poisson, with exact and cumulative probabilities.

  • Bayes — P(H|) = P(|H)·P(H)/P(+), shown as a tree of whole people and an icon array of 1,000 people (true and false positives, misses, true negatives). That makes it clear why a good test for a rare condition still gives mostly false positives. Slide the prevalence from 50 % down to 0.1 % on a log scale, and switch to two independent positives to see the first posterior become the second prior.

  • Bloom filter — sliders for the bits m, items n and hash functions k. It shows the fill 1 − e^(−kn/m), the false-positive rate (1 − e^(−kn/m))^k (and the exact form without the e approximation), the optimal k = (m/n) ln 2 and the best whole k, a log-scale curve of the false-positive rate against k, and a simulation: insert n items, query 20,000 that were never added, and compare measured with predicted. Filters up to 4,096 bits draw their bit array.

  • Spam filter — a naive Bayes classifier you train on a few spam and ham messages (one per line). Each word of the message gets P(word | spam) and P(word | ham) as the fraction of that class’s messages containing it, with add-α smoothing (hits + α)/(messages + 2α). The table shows every factor and its log ratio; the scores, their log difference and P(spam | message) follow. With α = 0, one word never seen in a class zeroes that class and the tool says so.

  • Reliability — describe a system of independent parts: s(…) in series (all must work), p(…) in parallel (any one is enough), kofn(2, …) voting, 0.99x3 for three identical parts, 99% for 0.99; nest freely, e.g. s(0.999, p(0.99x2), p(0.95x3)). You get the reliability, failure probability, "nines" and downtime per year, a block diagram, and each group’s calculation from the inside out. Below it, failures at scale: N units with a given MTBF fail together every MTBF ÷ N, with the failures per day, the expected number in a run, P(no failure) = e^(−N·T/MTBF), and how much time goes to recovery under a hot standby (tens of ms, twice the GPUs), warm standby (about a second, a shared cache tier) or cold restart (re-run the prefill).

  • Expected value and Monte Carlo — list outcomes as "probability, value". For anything harder, write one trial as JavaScript; it runs millions of times in a background Worker (stopped after 20 s) and reports the hit rate with a 95 % interval.

For learning and planning. Reliability and Bayes assume independence; correlated failures (a shared power supply) and correlated tests break the products.

Related: statistics, hashes (what a Bloom filter’s hash functions do), boolean logic (series is AND, parallel is OR).

Companion to AI Acceleration for failures at scale: why large training runs fail and recovery from request retries to KV-cache replication. One H100’s MTBF of about 50,000 hours is the figure the book’s failure arithmetic uses, and it matches Llama 3 405B’s 419 unexpected interruptions in 54 days on 16,384 GPUs.

Sharing

Share link (under the title) copies a URL that reopens this tool exactly as you have it — every tab’s inputs, with the current tab selected. Opening such a link replaces the inputs this browser had saved for the tool.

Linking to an example

Write a link by hand with these parameters, and add the tab after #: dice, count, cards, birthday, dist, bayes, bloom, spam, reliability or ev. Parameters you leave out take their defaults. In a URL, + means a space (handy in msg); write a real plus as %2B. Separate training messages with ; (or %0A). For example ?m=10000&items=1000&k=7#bloom or ?sys=s(0.99.

Parameter Meaning Example

dice, target

Dice notation and the target for P(total ≥ target)

dice=2d6&target=10

n, r

Combinations: items and how many are chosen

n=52&r=5

pool, pick, bonus

Lottery: pick this many from the pool, optional bonus-ball pool

pool=49&pick=6

hN, hK, hn, hk

Hypergeometric: population, successes in it, draws, successes wanted

hN=52&hK=4&hn=5&hk=2

people, days

Birthday problem: people and equally likely days (or hash values)

people=23&days=365

dn, dp, dk

Binomial n, p and k

dn=20&dp=0.3&dk=6

gp, gk

Geometric: p and the trial number

gp=0.1&gk=10

lam, pk

Poisson: rate λ and k

lam=3&pk=5

prior, sens, spec

Bayes: prevalence, sensitivity and specificity, all in %

prior=1&sens=99&spec=95

fpr

False-positive rate in %, instead of spec (spec = 100 − fpr)

fpr=5

pop, tests

Bayes: people in the tree; 2 for two independent positives

pop=10000&tests=2

m, items, k

Bloom filter: bits, items inserted, hash functions

m=10000&items=1000&k=7

spam, ham

Spam filter training messages, separated by ;

spam=free+money;win+free+prize

msg, alpha

The message to classify and the smoothing α

msg=prize+meeting&alpha=1

sys

Reliability system

sys=kofn(2,0.99x3)

mtbf, units, run

Failures at scale: one unit’s MTBF (hours), how many units, the window (hours)

mtbf=50000&units=16384&run=1296

post, rec

Recovery posture (hot, warm, cold, custom) and seconds to recover from each failure

post=hot&rec=0.02

ev, cost, trials

Expected value lines ("probability, value"), cost to play, Monte Carlo trials

cost=20

example

One of the presets below; parameters written beside it override the preset

example=ch29-bloom

Presets (?example=…; the link opens on the right tab even without #):

  • ch29-poker-two-aces — Exactly two aces in a five-card hand: 103 776 / 2 598 960 ≈ 4 %.

  • ch29-defective-batch — Test 4 of 20 chips with 3 bad: P(at least one) ≈ 0.509.

  • ch24-poker-hands — The ten five-card hand types with exact counts out of C(52,5) = 2 598 960.

  • ch29-two-dice-10 — Two dice, P(total ≥ 10) = 6/36.

  • ch29-servers-series — Three 99 % servers in series: 0.99³ ≈ 0.970.

  • ch29-servers-parallel — Three 99 % replicas in parallel: 1 − 0.01³ = six nines.

  • ch29-reliability-mixed — A load balancer, two app servers and three database replicas: nesting both rules.

  • ch29-reliability-vote — Two-out-of-three voting (a quorum): between series and parallel.

  • ch29-bayes-medical — 1 % prevalence, 99 % sensitivity, 5 % false positives: P(disease | +) = 99/594 = 1/6.

  • ch29-bayes-second-test — A second independent positive: from 1/6 to about 0.798.

  • ch29-bayes-fraud — Exercise: 2 % fraud, 95 % flagged, 3 % false flags, 100 000 transactions.

  • ch29-birthday — 23 people: P(shared birthday) = 0.507.

  • ch24-birthday-hash16 — 16-bit hash: a collision is an even bet after about 1.18·√65536 ≈ 302 items.

  • ch29-spam — The book’s training set; "free meeting" scores 0.075 vs 0.05, P(spam) = 0.6.

  • ch29-spam-zero — The zero-count problem: "prize" never appears in ham, so P(spam) = 1.

  • ch29-spam-smoothed — Laplace (add-one) smoothing: the same message scores 0.542.

  • ch29-bloom — 10 bits per item, 7 hashes: predicted 0.00819, measured about 0.008.

  • ch29-bloom-design — Exercise: m = 8 × 10⁶, n = 10⁶: best k = 6, false positives ≈ 0.0216.

  • p16-mtbf-16k — MTBF ÷ N: 50,000-hour GPUs, 16,384 of them, fail every ~3 hours (about 8 a day).

  • p16-llama3-405b — Llama 3 405B: 54 days on 16,384 H100s expects ~425 failures (Meta saw 419 unexpected interruptions).

  • ft-mtbf-10k — 10,000 GPUs at 50,000 hours each: a failure every 5 hours.

  • ft-mtbf-100k — A 100,000-GPU serving fleet: a failure every 30 minutes.

  • ft-hot-standby — Hot standby: ~20 ms failover at twice the decode GPUs, and a replicated pair of 99.9 % pods.

  • ft-warm-standby — Warm standby: ~1 s to pull the cache back from a shared tier, no spare GPUs.

  • ft-cold-restart — Cold restart: re-run prefill — about 10 s for 128k tokens of a 70B model on 8 H100s at half of peak.

Runs entirely in your browser; nothing you type leaves this page.