Skip to content
DeepForgeby svx
All problems

Sample Efficiency AUC

Problem

Compute the area under a learning curve with the trapezoid rule.

steps and rewards give the curve at checkpoints; sum 0.5 * (r_i + r_{i+1}) * (steps_{i+1} - steps_i). Fewer than two checkpoints returns 0.0.

Hint

The trapezoid rule handles unevenly spaced evaluation checkpoints.

Test cases

case 1
in: [[0,10,20],[0,10,20]]
expected: 200
case 2
in: [[0,5],[2,4]]
expected: 15
case 3
in: [[0],[5]]
expected: 0
case 4
in: [[0,10,20],[1,2,3]]
expected: 40
Starter codePython
def sample_efficiency_auc(steps, rewards):
    # Your code here
    pass

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