Skip to content
DeepForgeby svx
All problems
HardOptimizationop-183

Expected Improvement

Problem

Compute the expected improvement acquisition for minimization.

With z = (best - mu) / sigma, return (best - mu) * Phi(z) + sigma * phi(z), where Phi is the standard normal CDF and phi its PDF. When sigma <= 0 return max(0, best - mu).

Hint

The improvement is max(0, best - y), and its expectation has a closed form.

Test cases

case 1
in: [0,1,1]
expected: 1.0833154705876864
case 2
in: [2,0.5,1]
expected: 0.004245351308414823
case 3
in: [1,0,0.5]
expected: 0
case 4
in: [3,2,1]
expected: 0.16663094117537258
Starter codePython
def expected_improvement(mu, sigma, best):
    # Your code here
    pass

4 test cases · run your code against them in the editor