import random
# 定义基本参数
initial_salary_a = 25000 # 路径 A 初始薪资
initial_salary_b = 14000 # 路径 B 初始薪资
initial_salary_c = 5000 # 路径 C 初始薪资
savings_a = 400000 # 路径 A 初始存款
savings_b = 400000 # 路径 B 初始存款
savings_c = 0 # 路径 C 初始存款
mortgage_c = 600000 # 路径 C 房贷
first_tier_price = 5500000 # 一线城市房价
second_tier_price = 1500000 # 二线城市房价
salary_increase_prob_a = 0.3 # 一线城市薪资增长概率
salary_increase_prob_b = 0.3 # 二线城市薪资增长概率
layoff_prob = 0.1 # 被裁员概率
house_depreciation_prob_c = 0.4 # 老家房子贬值概率
salary_usable_ratio = 0.65 # 薪资中可用于支出的比例
duration = 15 * 12 # 模拟时间(月)
# 模拟函数
def simulate_path_with_negatives(path):
import random
# 基本参数
initial_salary_a = 25000
initial_salary_b = 14000
initial_salary_c = 5000
savings_a = 400000
savings_b = 400000
savings_c = 0
mortgage_c = 600000
first_tier_price = 5500000
second_tier_price = 1500000
duration = 15 * 12
salary_usable_ratio = 0.65
# 事件概率
salary_increase_prob_a = 0.3
salary_increase_prob_b = 0.3
layoff_prob = 0.1
house_depreciation_prob_c = 0.4
# 模拟函数
def simulate_path(path):
salary = initial_salary_a if path == 'A' else initial_salary_b if path == 'B' else initial_salary_c
savings = savings_a if path == 'A' else savings_b if path == 'B' else savings_c
mortgage_remaining = mortgage_c if path == 'C' else 0
progress = 0
married = False
house_bought = False
car_bought = False
for month in range(duration):
if path == 'A' and random.random() < salary_increase_prob_a:
salary *= 1.1
elif path == 'B' and random.random() < salary_increase_prob_b:
salary *= 1.1
if path == 'A' and random.random() < layoff_prob:
salary = 0
elif path == 'B' and random.random() < layoff_prob:
salary *= 0.5
usable_salary = salary * salary_usable_ratio
savings += usable_salary
if not car_bought and month >= 60:
car_bought = True
progress += 10
if not house_bought and (savings >= first_tier_price * 0.35 if path == 'A' else savings >= second_tier_price * 0.35):
house_bought = True
savings -= first_tier_price * 0.35 if path == 'A' else second_tier_price * 0.35
progress += 30
if not married and (house_bought or path == 'C'):
married = True
progress += 20
if path == 'C' and random.random() < house_depreciation_prob_c:
mortgage_remaining *= (1 - 0.35)
if path == 'C' and mortgage_remaining > 0:
repayment = min(mortgage_remaining, usable_salary)
mortgage_remaining -= repayment
savings -= repayment
if mortgage_remaining == 0:
progress += 20
if salary == 0 and month % 3 == 0:
salary = initial_salary_a if path == 'A' else initial_salary_b if path == 'B' else initial_salary_c
return progress
progress_a = simulate_path('A')
progress_b = simulate_path('B')
progress_c = simulate_path('C')
# a=60% b=60% c=50%
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.