All problems
Certainty Equivalent
Problem
Compute the certainty equivalent of a gamble under CRRA utility.
For gamma equal to 1 use exp(sum(probs[i] * ln(wealths[i]))). Otherwise return (sum(probs[i] * wealths[i] ** (1 - gamma))) ** (1 / (1 - gamma)).
Hint
The certainty equivalent is the inverse utility of the expected utility.
Test cases
case 1
in: [[100,50],[0.5,0.5],2]
expected: 66.66666666666667
case 2
in: [[100,50],[0.5,0.5],1]
expected: 70.71067811865478
case 3
in: [[10],[1],0.5]
expected: 10.000000000000002
Starter codePython
def certainty_equivalent(wealths, probs, gamma):
# Your code here
pass3 test cases · run your code against them in the editor