-
完整条件
初始条件
- 一线城市房价:550 万
- 二线城市房价:150 万
路径 A (继续在一线城市工作):
- 初始薪资:25,000 元/月
- 无房,存款老家房子,折现 40 万
路径 B (到二线城市工作):
- 初始薪资:14,000 元/月
- 存款老家房子,折现 40 万
路径 C (回老家):
- 初始薪资:5,000 元/月
- 有房贷 60 万
事件概率和影响
-
路径 A:
- 好事:薪资每年上涨 10%,概率为 30%
- 坏事:被裁员,失去固定薪资 3 个月,概率为 10%
- 期望事件进度:5 年后买车,买房(首付 35%),结婚
-
路径 B:
- 好事:薪资为一线城市的 90%,概率为 60%;薪资增长概率为 30%
- 坏事:水土不服,长期待业或只有原薪资 50%,概率为 10%
- 期望事件进度:买房,5 年后买车,结婚
-
路径 C:
- 好事:薪资为一线城市的 50%,概率为 30%;正常为 20%-30%
- 坏事:老家房子贬值 30%-40%,概率为 40%
- 期望事件进度:还清房贷,结婚
模拟的关键变量
- 每月薪资的 65%可用于支出房子和车子
- 存款的累积和更新
- 每月薪资的变化
- 特定事件(如买车、买房、结婚)对总进度的影响
- 随机事件的发生概率
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%