-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathrisk_aversion.py
36 lines (24 loc) · 938 Bytes
/
risk_aversion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Compute the utility value of monetary quantities under prospect theory
"""
from functools import partial
def power_utility_loss_aversion(z, ɣ, λ):
"""Return the utility evaluation of a monetary quantity z under power
utility with utility curvature parameter ɣ and loss aversion
parameter λ.
"""
out = z ** (1 - ɣ) if z >= 0 else -λ * (-z) ** (1 - ɣ)
return out
# Define the characteristics of the individual.
power_coefficient = 0.5
loss_aversion_coefficient = 2.0
# Define this individual's utility.
individuals_utility = partial(
power_utility_loss_aversion, ɣ=power_coefficient, λ=loss_aversion_coefficient
)
# Define the monetary payoffs.
payoffs = [500, -550]
# Set up the calculation of the utility values via list comprehension.
out = [individuals_utility(payoff) for payoff in payoffs]
# Carry out the computations and print them to the screen.
for item in out:
print(item)