All problems
Contrastive Information Gap
Problem
Return the contrastive information gap in bits: the average negative similarity minus the positive similarity, converted from nats to bits by dividing by ln(2).
Hint
A large gap means the positive pair is far more similar than unrelated pairs.
Test cases
case 1
in: [1,[0,0]]
expected: -1.4426950408889634
case 2
in: [0.5,[1,2]]
expected: 1.4426950408889634
case 3
in: [0,[0,0]]
expected: 0
case 4
in: [2,[1]]
expected: -1.4426950408889634
Starter codePython
import math
def contrastive_information_gap(pos_sim, neg_sims):
# Your code here
pass4 test cases · run your code against them in the editor