fix(critical): complete Zt sign alignment across all modules
Fixed ALL instances of (d - sqrt_rho*z) -> (d + sqrt_rho*z): - models/vasicek.py: conditional_transition_matrix() (used by lifetime PD) - data/transition_matrices.py: _generate_model_consistent_matrix() - models/credit_cycle.py: already fixed in previous commit Added sign convention docs: - vasicek.py conditional_pd() uses Basel convention (Z↑=loss↑) - conditional_transition_matrix() uses Belkin convention (Z↑=호황) - Both conventions documented in module docstrings Pipeline 8/8 validation pass after fix
This commit is contained in:
@@ -128,18 +128,18 @@ def _generate_model_consistent_matrix(
|
||||
cum_prob_clipped = np.clip(cum_prob, 1e-10, 1.0 - 1e-10)
|
||||
thresholds[i, j] = norm.ppf(cum_prob_clipped)
|
||||
|
||||
# 2. Z-조건부 전이확률 계산
|
||||
# 2. Z-조건부 전이확률 계산 (Belkin convention: Z>0 = 호황)
|
||||
cond_tm = np.zeros((n, n))
|
||||
for i in range(n - 1):
|
||||
for j in range(n):
|
||||
d_upper = thresholds[i, j]
|
||||
upper = norm.cdf((d_upper - sqrt_rho * z) / sqrt_1_rho)
|
||||
upper = norm.cdf((d_upper + sqrt_rho * z) / sqrt_1_rho)
|
||||
|
||||
if j == 0:
|
||||
lower = 0.0
|
||||
else:
|
||||
d_lower = thresholds[i, j - 1]
|
||||
lower = norm.cdf((d_lower - sqrt_rho * z) / sqrt_1_rho)
|
||||
lower = norm.cdf((d_lower + sqrt_rho * z) / sqrt_1_rho)
|
||||
|
||||
cond_tm[i, j] = max(upper - lower, 0.0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user