All problems
Uniform Differential Entropy
Problem
The differential entropy of a continuous uniform distribution on (a, b) is ln(b - a). Return 0.0 when b <= a.
Hint
Entropy grows with the logarithm of the interval width.
Test cases
case 1
in: [0,1]
expected: 0
case 2
in: [0,2]
expected: 0.6931471805599453
case 3
in: [1,5]
expected: 1.3862943611198906
case 4
in: [2,2]
expected: 0
case 5
in: [3,1]
expected: 0
Starter codePython
import math
def uniform_differential_entropy(a, b):
# Your code here
pass5 test cases · run your code against them in the editor