← 返回题库
中级

HARA效用函数

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve(____):
    if hara_type == "____":
        gamma = params.get(____)
        utility = wealth ** (____ - gamma) / (____ - gamma) if gamma != ____ else np.log(____)
    elif hara_type == "____":
        a = params.get(____)
        utility = -np.exp(____)
    else:
        a, b, c = params.get(____), params.get(____), params.get(____)
        utility = a * (____) ** (____ - c) / (____ - c)
    return {"____": hara_type, "____": wealth, "____": round(____)}
import numpy as np

示例

输入
solve(100, {"gamma": 2}, "CRRA")
期望输出
{'效用类型': 'CRRA', '财富': 100, '效用值': -0.01}
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码