All problems
Convex Conjugate of exp
Problem
Return the convex conjugate of f(x) = exp(x):
f*(y) = sup_x (x * y - exp(x)) = y * ln(y) - y for y > 0
and 0 at y = 0.
Hint
The conjugate of the exponential is the negative entropy of a Poisson-like variable.
Test cases
case 1
in: [1]
expected: -1
case 2
in: [2]
expected: -0.6137056388801094
case 3
in: [0.5]
expected: -0.8465735902799727
case 4
in: [0]
expected: 0
Starter codePython
import math
def convex_conjugate_exp(y):
# Your code here
pass4 test cases · run your code against them in the editor