Update your belief about a model's pass rate with a Beta prior
You run an agent on tasks and it passes some. With only 10 runs, 9 passes does not mean 90 percent. A Beta(a, b) prior plus pass/fail counts gives a Beta(a + passes, b + fails) posterior.
Write beta_update(a, b, results) where results is a list of 1 (pass) and 0 (fail). Return (post_a, post_b, mean, var) for the posterior, where for Beta(a, b):
mean = a / (a + b)
var = a b / ((a + b) ** 2 (a + b + 1))
def beta_update(a, b, results)Understand the idea
A Beta(a, b) distribution describes your belief about an unknown success rate. You can read a as imaginary passes and b as imaginary fails seen before any data. Each real pass adds 1 to a and each fail adds 1 to b, so updating is just counting. This keeps small samples from looking extreme, like not trusting a new restaurant's perfect score after two reviews. Worked example: prior Beta(1, 1), results with 9 passes and 1 fail. Posterior is Beta(10, 2). Mean = 10 / 12 = 0.833, not 0.9. Variance = (10 x 2) / (12^2 x 13) = 20 / 1872 = 0.0107. Rule: post_a = a + passes, post_b = b + fails; mean = a / (a + b); var = a b / ((a + b)^2 (a + b + 1)) using the posterior values. Teams use this to report agent or model pass rates with honest uncertainty when the eval set is small.