Skip to content
DeepForgeby svx
All problems

Bradley-Terry Likelihood

Problem

Compute the Bradley-Terry probability that the first item is preferred: sigmoid(r1 - r2) = 1 / (1 + exp(-(r1 - r2))).

Hint

Equal rewards give a fifty-fifty preference.

Test cases

case 1
in: [0,0]
expected: 0.5
case 2
in: [2,0]
expected: 0.8807970779778823
case 3
in: [0,2]
expected: 0.11920292202211755
Starter codePython
import math
def bradley_terry_likelihood(r1, r2):
    # Your code here
    pass

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