Skip to content

Commit

Permalink
fix sign of inf in log of zero
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez committed Jan 24, 2024
1 parent 678364e commit 1ff6b61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions nbs/src/arima.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1258,8 +1258,8 @@
" x -= np.dot(xreg, par[narma + np.arange(ncxreg)])\n",
" \n",
" res, resid = arima_css(x, arma, phi, theta, ncond)\n",
" if res == 0.0:\n",
" return math.inf\n",
" if res <= 0.0:\n",
" return -math.inf\n",
" return 0.5 * math.log(res)\n",
" \n",
" coef = np.array(fixed)\n",
Expand Down
4 changes: 2 additions & 2 deletions statsforecast/arima.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,8 +890,8 @@ def arma_css_op(p, x):
x -= np.dot(xreg, par[narma + np.arange(ncxreg)])

res, resid = arima_css(x, arma, phi, theta, ncond)
if res == 0.0:
return math.inf
if res <= 0.0:
return -math.inf
return 0.5 * math.log(res)

coef = np.array(fixed)
Expand Down

0 comments on commit 1ff6b61

Please sign in to comment.