All problems
CRRA Log Utility Maximization
Problem
Compute the optimal fraction of wealth invested in a binary gamble under log utility.
The gamble gains r_gain with probability p and loses r_loss otherwise. Maximizing p * ln(1 + alpha * r_gain) + (1 - p) * ln(1 + alpha * r_loss) gives alpha = -(p * r_gain + (1 - p) * r_loss) / (r_gain * r_loss). Return that fraction, or 0.0 when the denominator is zero.
Hint
The first-order condition is linear in the fraction for log utility.
Test cases
case 1
in: [0.6,0.2,-0.1]
expected: 3.9999999999999987
case 2
in: [0.5,0.1,-0.1]
expected: 0
case 3
in: [0.8,0.05,-0.2]
expected: 1.3877787807814455e-15
Starter codePython
def crra_log_optimal_fraction(p, r_gain, r_loss):
# Your code here
pass3 test cases · run your code against them in the editor