in src/sal/utils/math.py [0:0]
def pass_at_k(n: int, c: int, k: int) -> float:
"""A numerically stable method for calculating an unbiased estimate of pass@k.
Taken from OpenAI's Codex paper: https://arxiv.org/abs/2107.03374
Args:
n (`int`): total number of samples
c (`int`): number of correct samples
k (`int`): k in pass@$k$
Returns:
`float`: an unbiased estimate of pass@k
"""
if n - c < k:
return 1.0
return 1.0 - np.prod(1.0 - k / np.arange(n - c + 1, n + 1))