All problems
Pass@k from Correct Rate
Problem
Given c correct completions out of n samples, treat p = c / n as the per-sample success probability and return the binomial pass@k probability 1 - (1 - p)^k. Return 0.0 when n <= 0, k <= 0, or c <= 0, and 1.0 when c >= n.
Test cases
case 1
in: [2,10,5]
expected: 0.6723199999999999
case 2
in: [1,4,2]
expected: 0.4375
case 3
in: [0,5,3]
expected: 0
case 4
in: [5,5,2]
expected: 1
case 5
in: [3,4,1]
expected: 0.75
Starter codePython
def pass_at_k_rate(c, n, k):
# Your code here
pass5 test cases · run your code against them in the editor