算法中的最大化、最小化与排序搜索
1. 教育与收入的梯度上升
在探讨教育与收入的关系时,我们发现高中毕业后直接进入职场的人,在短期内可能比继续深造几个月的人收入更高,因为深造者错过了这几个月的赚钱机会。然而,经过几年的大学教育后,考虑到上学期间损失的潜在收入,大学生获得的技能使其一生的收入超过高中毕业生。
1.1 教育与收入曲线
教育与收入曲线比税收 - 收入曲线更复杂,它有一个全局最大值,也有几个低于全局最大值的局部最大值。以下是用于计算收入导数的代码:
import math
def income_derivative(edu_yrs):
return(math.cos((edu_yrs - 10.6) * (2 * math.pi/4)) + 1/2)
threshold = 0.0001
maximum_iterations = 100000
current_education = 12.5
step_size = 0.001
keep_going = True
iterations = 0
while(keep_going):
education_change = step_size * income_derivative(current_education)
current_education = current_education + education_change
if(abs(education_change) < threshold):
keep_going = False
if(iterations &g
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



