-
-
Notifications
You must be signed in to change notification settings - Fork 210
Fix CRRA=1.0 division by zero errors across consumption models #1587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
ec458aa
1b45291
0bb4852
c01a227
31ca7ca
f5d610d
18b4067
466b83e
9545127
5df8bd9
fb44fe1
50cfac2
22e7342
017725e
7855b2c
4833249
f64db8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -345,9 +345,15 @@ def calc_vPPnext(S, a, R): | |||||||
| vNvrs_temp = uFunc.inv(v_temp) | ||||||||
| vNvrsP_temp = vP_temp * uFunc.derinv(v_temp, order=(0, 1)) | ||||||||
| mNrm_temp = np.insert(mNrm_temp, 0, mNrmMinNow) | ||||||||
| vNvrs_temp = np.insert(vNvrs_temp, 0, 0.0) | ||||||||
| vNvrsP_temp = np.insert(vNvrsP_temp, 0, MPCmaxEff ** (-CRRA / (1.0 - CRRA))) | ||||||||
| MPCminNvrs = MPCminNow ** (-CRRA / (1.0 - CRRA)) | ||||||||
| vNvrs_temp = np.insert(vNvrs_temp, 0, 0.0) # Handle CRRA=1.0 case to avoid division by zero | ||||||||
|
alanlujan91 marked this conversation as resolved.
Outdated
|
||||||||
| if CRRA == 1.0: | ||||||||
| # When CRRA=1.0, use a small epsilon to avoid division by zero | ||||||||
| CRRA_safe = 1.0 + 1e-8 | ||||||||
|
alanlujan91 marked this conversation as resolved.
Outdated
|
||||||||
| vNvrsP_temp = np.insert(vNvrsP_temp, 0, MPCmaxEff ** (-CRRA_safe / (1.0 - CRRA_safe))) | ||||||||
| MPCminNvrs = MPCminNow ** (-CRRA_safe / (1.0 - CRRA_safe)) | ||||||||
| else: | ||||||||
| vNvrsP_temp = np.insert(vNvrsP_temp, 0, MPCmaxEff ** (-CRRA / (1.0 - CRRA))) | ||||||||
| MPCminNvrs = MPCminNow ** (-CRRA / (1.0 - CRRA)) | ||||||||
| vNvrsFuncNow = CubicInterp( | ||||||||
| mNrm_temp, vNvrs_temp, vNvrsP_temp, MPCminNvrs * hNrmNow, MPCminNvrs | ||||||||
| ) | ||||||||
|
|
@@ -656,9 +662,15 @@ def calc_vPPnext(S, a, R): | |||||||
| vNvrs_temp = uFunc.inv(v_temp) | ||||||||
| vNvrsP_temp = vP_temp * uFunc.derinv(v_temp, order=(0, 1)) | ||||||||
| mNrm_temp = np.insert(mNrm_temp, 0, mNrmMinNow) | ||||||||
| vNvrs_temp = np.insert(vNvrs_temp, 0, 0.0) | ||||||||
| vNvrsP_temp = np.insert(vNvrsP_temp, 0, MPCmaxEff ** (-CRRA / (1.0 - CRRA))) | ||||||||
| MPCminNvrs = MPCminNow ** (-CRRA / (1.0 - CRRA)) | ||||||||
| vNvrs_temp = np.insert(vNvrs_temp, 0, 0.0) # Handle CRRA=1.0 case to avoid division by zero | ||||||||
|
||||||||
| vNvrs_temp = np.insert(vNvrs_temp, 0, 0.0) # Handle CRRA=1.0 case to avoid division by zero | |
| vNvrs_temp = np.insert(vNvrs_temp, 0, 0.0) | |
| # Handle CRRA=1.0 case to avoid division by zero |
Uh oh!
There was an error while loading. Please reload this page.