Implement an Unbiased Pass At K Estimator for Code Generation
Last updated: November 29, 2026
Quick Overview
For each benchmark problem a code model produced n samples, of which c pass the hidden tests. Write a numerically stable function for the unbiased pass@k estimate and the benchmark mean, and explain why 1 - (1 - c/n)^k is biased.
Turing
November 29, 20260
0
0 solved
For each benchmark problem a code model produced n samples, of which c pass the hidden tests. Write a numerically stable function for the unbiased pass@k estimate and the benchmark mean, and explain why 1 - (1 - c/n)^k is biased.
Turing builds coding benchmarks and RL environments for frontier labs, so reporting model capability correctly is part of the job. The interviewer checks both the combinatorics and the engineering detail of avoiding overflow with large n.
What the Interviewer Expects
- Derives pass@k as 1 - C(n-c, k) / C(n, k)
- Explains why the naive plug-in estimator is biased
- Uses a product form to avoid huge binomial coefficients
- Handles the case n - c < k
- Averages per problem, not per sample
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How many samples n would you draw per problem to report pass@10 with low variance?
- How would you put a confidence interval on benchmark-level pass@1?
- What goes wrong if some problems have flaky tests?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input per problem: n samples drawn, c correct. pass@k is the probability that at least one of k samples, drawn without replacement from the n, is correct. Return a float per problem and the mean a...
High-Level Design
The probability that all k chosen samples are wrong is C(n-c, k) / C(n, k), so pass@k = 1 - C(n-c, k)/C(n, k). This is unbiased for the model's true pass@k when we draw n >= k samples. The plug-in est...