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.58k stars 368 forks source link

Round the Pathfinder Pareto k-value #3278

Closed avehtari closed 5 months ago

avehtari commented 6 months ago

Currently, Pathfinder warns, for example

Pareto k value (1.487590) is greater than 0.7. Importance resampling was not able to improve the approximation, which may indicate that the approximation itself is poor. 

It would be better to round the Pareto k value to max 2 decimal digits as the extra digits are just a distraction. Often 1 digit would be sufficient, but 2 digits can be useful near the diagnostic boundary.

psis.hpp uses std::to_string which prints as if using std::sprintf(buf, "%f", value) and there is no control of number of digits. https://github.com/stan-dev/stan/blob/73d9b01d2851d6dd98f1e43dcb56735c20da6cef/src/stan/services/pathfinder/psis.hpp#L265