stan-dev / stan

Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
2.6k stars 370 forks source link

Replace all non-finite lp__ and lp_approx__ with -Inf #3290

Closed avehtari closed 5 months ago

avehtari commented 6 months ago

When drawing from Laplace, variational, or Pathfinder approximation, in rare cases we see NaN or Inf for lp__ or lp_approx__ written in csv. From the further usage point of view, it would be useful if all NaN and Inf would be converted to -Inf.

The downside is that it may sometimes make it more difficult to find out numerically unstable computation in code (ie observing NaN or Inf gives non-zero information where the issue might be).

SteveBronder commented 5 months ago

imo I've found that receiving back NaN or +/-Inf gave me different info about debugging the program. If we give back a user -inf instead of NaN