How good is a code model if you let it try k times? Generate n ≥ k samples per problem, count the c that pass the tests, and use the unbiased estimator from the Codex paper:
Binomials overflow quickly for large n, so compute it as a product: . If , the answer is exactly 1.0.
Implement pass_at_k(n, c, k) and mean_pass_at_k(results, k), where results is a list of (n, c) pairs, one per problem.