Bugfix/issue 376 phi tails by bob-carpenter · Pull Request #430 · stan-dev/stan
Summary
Fix #376 by expanding domain of stan::math::Phi as far as is possible (on the non-log scale) using double precision floating point.
Intended Effect
- explicitly underflow to 0 for inputs less than -37.5 without calling erfc()
- use erfc() instead of erf() for negative args below -5,
- explicitly overflow to 0 for inputs greater than 8.25 without calling erf()
- use erfc() otherwise
No change on derivative behavior.
Example
Phi(-35) no longer underflows. See the unit tests for a complete test of the defined range and the agrad tests for tests of the derivative range.
Side Effects
None.
Documentation
Added doc for underflow behavior of Phi and its derivatives to the manual.
Reviewer Suggestions
Anyone.
Does anyone know if there's a better way to test extreme values than EXPECT_FLOAT_EQ(1, expected / found) ?