This page is a firing range . The parent note gave you two engines — Pass@k for objective benchmarks and Cohen's Kappa for LLM-as-judge agreement. Here we fire them at every case that can appear: the easy ones, the sign traps, the degenerate zero-inputs, the limiting values, and the exam twists.
Intuition Why "every scenario" matters here
A formula that works on the textbook example but breaks when c = 0 or c = n is a landmine. Evaluators run these numbers on thousands of problems automatically — one problem where every sample failed (c = 0 ), or where the judge always agreed by luck (p e = 1 ), and a naive script divides by zero or reports nonsense. We walk each cell so you never get surprised.
Before defining a single symbol again, here is the map of every kind of situation the two formulas face. Read the columns as "what makes this case special."
Cell
Formula
The special condition
What breaks / what to watch
C1
Pass@k
Typical case: 0 < c < n
Nothing special — baseline
C2
Pass@k
Degenerate low : c = 0 (no sample ever passed)
Estimator says 0 ; must not error
C3
Pass@k
Degenerate high : c = n (every sample passes)
Estimator says 1 ; combinatorial form has ( k 0 )
C4
Pass@k
Limiting k → large vs k = 1
How the score grows with more tries
C5
Pass@k
Unbiased combinatorial estimator on ONE problem
Sampling-without-replacement form
C6
Kappa
Typical moderate agreement
Baseline judge-vs-human
C7
Kappa
Degenerate : judge and human always pick the same side (p e → 1 )
Denominator 1 − p e → 0
C8
Kappa
Negative kappa : judge does worse than chance
Sign of κ goes below 0
C9
Both
Real-world word problem : end-to-end eval report
Combine both metrics
C10
Kappa
Exam twist : given κ and p e , recover p o
Algebra inversion
We now hit every cell.
Recall Pass@k — what each letter means
n ::: total number of code samples drawn for one problem
c ::: how many of those n samples passed all hidden tests
k ::: how many samples we "get to try" (report at)
Pass@ k ::: the probability that at least one of k tries succeeds
Recall Cohen's Kappa — what each letter means
p o ::: observed agreement, the fraction of comparisons where judge and human chose the same winner
p e ::: agreement expected by pure chance
κ ::: agreement beyond chance, on a scale where 1 is perfect and 0 is "no better than luck"
The two forms we will use:
Pass@ k = 1 − ( k n ) ( k n − c ) , κ = 1 − p e p o − p e
The symbol ( k n ) ("n choose k ") counts how many ways to pick k items out of n when order does not matter. We use it because "which k samples did the judge happen to draw" is exactly an unordered choice.
0 < c < n
A problem has n = 10 samples generated. Of them, c = 3 passed all tests. Report Pass@2 .
Forecast: Guess before computing — should Pass@2 be bigger or smaller than the single-sample rate 3/10 = 0.30 ? (Two tries should help, so bigger .)
Count the failing samples: n − c = 10 − 3 = 7 .
Why this step? Pass@k is easiest as "1 minus the chance both tries land in the failing pile."
Chance both drawn samples are failures (drawing 2 of the 7 failures out of all 10):
( 2 10 ) ( 2 7 ) = 45 21 .
Why this step? ( 2 7 ) = ways to pick 2 losers; ( 2 10 ) = ways to pick any 2. Their ratio is the probability of "all failed."
Subtract from 1:
Pass@ 2 = 1 − 45 21 = 45 24 ≈ 0.5333.
Verify: 0.533 > 0.30 ✓ (two tries beat one). And it is below 1 because success is not guaranteed. Units: a probability, dimensionless, in [ 0 , 1 ] ✓.
Worked example C2: no sample ever passed
n = 10 , c = 0 . Compute Pass@3.
Forecast: If nothing passed, more tries cannot help. Predict 0 .
Failing pile = n − c = 10 . All samples are failures.
Chance all 3 drawn are failures: ( 3 10 ) ( 3 10 ) = 1 .
Why this step? Every possible draw is a failure, so "all failed" is certain.
Pass@ 3 = 1 − 1 = 0 .
Verify: Matches the shortcut estimator 1 − ( 1 − 0/10 ) 3 = 1 − 1 3 = 0 ✓. No division by zero — ( 3 10 ) is well-defined. ✓
c = 0 trap
A buggy script might compute p ^ = c / n = 0 then take log p ^ somewhere — log 0 crashes. Always compute Pass@k directly, never through a log of the pass rate.
Worked example C3: every sample passes
n = 5 , c = 5 . Compute Pass@2.
Forecast: If everything passes, any single try wins. Predict 1 .
Failing pile = n − c = 0 .
Chance both drawn are failures: ( 2 5 ) ( 2 0 ) . Here ( 2 0 ) = 0 (you cannot choose 2 items from an empty set).
Why this step? Recognizing ( 2 0 ) = 0 is the whole point — this is where naive code returns a wrong "nan."
Pass@ 2 = 1 − 0 = 1 .
Verify: Shortcut: 1 − ( 1 − 5/5 ) 2 = 1 − 0 2 = 1 ✓.
The next figure shows why more tries always help but with shrinking returns .
Worked example C4: how Pass@k grows with
k
A problem has a true single-sample pass probability p = 0.30 . Compare Pass@1, Pass@2, Pass@5 using the independent-sample form Pass@ k = 1 − ( 1 − p ) k .
Forecast: Rising toward 1, but each extra try adds less than the last.
Pass@ 1 = 1 − ( 0.7 ) 1 = 0.30 .
Pass@ 2 = 1 − ( 0.7 ) 2 = 1 − 0.49 = 0.51 .
Pass@ 5 = 1 − ( 0.7 ) 5 = 1 − 0.16807 = 0.83193 .
Why this step? ( 1 − p ) k is the chance of k independent failures; it shrinks geometrically, so its complement climbs toward 1 .
Verify: Look at the red curve in the figure — it flattens toward 1 but never touches it. Gains: + 0.21 then only + 0.32 over three more tries ✓ diminishing returns.
Intuition The two Pass@k forms agree in the limit
The combinatorial form (sampling without replacement from n real samples) and the 1 − ( 1 − p ) k form (independent draws) give the same answer when n is large. The combinatorial one is the honest estimator for a finite generated set; the exponential one is the clean limit.
Worked example C5: the sampling-without-replacement form
We generated n = 20 samples, c = 4 passed. Report the unbiased Pass@10.
Forecast: With 4 winners in 20, and drawing 10, it's quite likely to grab at least one. Guess > 0.9 .
Probability all 10 drawn are from the 16 failures:
( 10 20 ) ( 10 20 − 4 ) = ( 10 20 ) ( 10 16 ) = 184756 8008 .
Why this step? This is the exact chance of missing every winner when you draw 10 of 20 without replacement.
184756 8008 ≈ 0.04334 .
Pass@ 10 = 1 − 0.04334 ≈ 0.95666 .
Verify: > 0.9 ✓. Because we draw half the samples, missing all 4 winners is rare, so the score is high ✓.
This reproduces the parent's headline number, so you can trust the machinery.
Worked example C6: baseline judge-vs-human agreement
Over n = 100 comparisons the judge and humans agreed 80 times. Human picks A 60% of the time; judge picks A 55% of the time. Compute κ .
Forecast: p o = 0.80 is high, but coin-level agreement is around 0.5 , so κ lands in the "moderate–substantial" band, not near 0.8 .
p o = 80/100 = 0.80 .
Expected-by-chance agreement:
p e = P ( both A ) + P ( both B ) = 0.60 × 0.55 + 0.40 × 0.45 = 0.33 + 0.18 = 0.51.
Why this step? If the two were independent, they'd coincide on A with probability (human A)× (judge A), and on B similarly. Sum = total chance coincidence.
κ = 1 − 0.51 0.80 − 0.51 = 0.49 0.29 ≈ 0.5918.
Verify: 0.59 falls in [ 0.4 , 0.6 ] = moderate ✓, matching the parent note.
Worked example C7: judge and human almost always pick A
p o = 0.98 , but the human picks A 99% of the time and the judge picks A 99% of the time. Compute κ .
Forecast: High raw agreement, but almost all of it is "everyone says A anyway" — expect a low kappa despite p o = 0.98 .
p e = 0.99 × 0.99 + 0.01 × 0.01 = 0.9801 + 0.0001 = 0.9802.
κ = 1 − 0.9802 0.98 − 0.9802 = 0.0198 − 0.0002 ≈ − 0.0101.
Why this step? The denominator 1 − p e = 0.0198 is tiny — kappa becomes hypersensitive; a hair below p e flips it negative.
Verify: Near-zero (slightly negative) ✓. The red bar in the figure shows the shrinking gap 1 − p e ; as it collapses, κ becomes unstable — this is the "kappa paradox" for lopsided classes.
Common mistake Reading high
p o as good agreement
When one option dominates, p e approaches 1 and κ can be near 0 even at p o = 0.98 . Always report p e alongside κ .
Worked example C8: the judge systematically disagrees
p o = 0.40 , human picks A 50% , judge picks A 50% . Compute κ .
Forecast: Chance agreement is 0.5 , but observed is only 0.4 — worse than luck. Predict κ < 0 .
p e = 0.5 × 0.5 + 0.5 × 0.5 = 0.25 + 0.25 = 0.50.
κ = 1 − 0.50 0.40 − 0.50 = 0.50 − 0.10 = − 0.20.
Verify: Negative ✓ — the judge agrees less than a coin would, signalling a systematic bias (e.g., position bias: always preferring the first-listed answer). Randomizing A/B order fixes this class of failure.
Worked example C9: an end-to-end evaluation report
You are comparing two chat models. For HumanEval , model X solved at least one of k = 5 samples on c = 82 of n = 164 problems — report Pass@5 as the simple estimator 1 − ( 1 − c / n ) 5 ... wait , that misuses the formula. The parent's simple estimator uses the per-problem pass rate. Here instead we're given that across 164 problems, 82 had "at least one success." That is already Pass@5 directly:
Pass@ 5 = 164 82 = 0.50.
Then, on AlpacaEval , an LLM judge and humans agree on 170 of 200 pairwise comparisons; humans pick X 45% of the time, judge picks X 48% of the time. Report κ .
Forecast: Pass@5 = 0.50 exactly; kappa should be solidly "substantial" since p o = 0.85 is well above chance.
Pass@ 5 = 82/164 = 0.50 .
Why this step? "Fraction of problems with ≥ 1 passing sample" is the definition of Pass@k when we count per problem.
p o = 170/200 = 0.85 .
p e = 0.45 × 0.48 + 0.55 × 0.52 = 0.216 + 0.286 = 0.502.
κ = 1 − 0.502 0.85 − 0.502 = 0.498 0.348 ≈ 0.6988.
Verify: κ ≈ 0.70 sits in [ 0.6 , 0.8 ] = substantial ✓. Report reads: "Model X passes half of HumanEval@5; the judge substantially agrees with humans, so its AlpacaEval win rates are trustworthy." Cross-links: this pipeline feeds RLHF reward signals and interacts with the Alignment Tax .
Worked example C10: recover
p o from κ and p e
An exam states: "A judge achieves κ = 0.75 with expected chance agreement p e = 0.40 . What was the observed agreement p o ?"
Forecast: p o must exceed p e = 0.40 and lie below 1 .
Start from κ = 1 − p e p o − p e and solve for p o :
p o = κ ( 1 − p e ) + p e .
Why this step? Multiply both sides by ( 1 − p e ) , then add p e — plain algebra, isolating the unknown.
Substitute: p o = 0.75 × ( 1 − 0.40 ) + 0.40 = 0.75 × 0.60 + 0.40 = 0.45 + 0.40 = 0.85.
Verify: Plug back: κ = ( 0.85 − 0.40 ) / ( 1 − 0.40 ) = 0.45/0.60 = 0.75 ✓. And 0.40 < 0.85 < 1 ✓.
Recall Quick self-test
Pass@k when c = 0 ::: always 0 — no try can succeed
Pass@k when c = n ::: always 1 — any try succeeds; note ( k 0 ) = 0
Why report p e next to κ ::: when one label dominates, p e → 1 and κ misleads even at high p o
Sign of κ below zero means ::: judge agrees worse than chance — likely a systematic bias
Invert kappa: p o = ::: κ ( 1 − p e ) + p e
Mnemonic "Complement, then correct"
Pass@k : take the complement (chance of all-fail) then subtract from 1.
Kappa : take raw agreement then correct for chance.
Both are "don't trust the raw number — adjust it."
Related tooling and ideas: Prompt Engineering Best Practices shape the judge prompt, Few-Shot Learning can calibrate the judge, Constitutional AI supplies judging criteria, and evaluation of RAG systems layers retrieval-quality on top of these same metrics. The judge's verdict tokens are A , B , or Tie .