All problems
Pinsker Total Variation Bound
Problem
Pinsker's inequality bounds the total variation distance between two distributions by sqrt(KL / 2), where KL is their Kullback-Leibler divergence. Return that bound for the given kl, and 0.0 when kl < 0.
Hint
Take the square root of half the KL divergence.
Test cases
case 1
in: [0.5]
expected: 0.5
case 2
in: [2]
expected: 1
case 3
in: [0]
expected: 0
case 4
in: [0.02]
expected: 0.1
case 5
in: [-1]
expected: 0
Starter codePython
import math
def pinsker_tv_bound(kl):
# Your code here
pass5 test cases · run your code against them in the editor