improve numerical stability of the Rice distribution

this is a follow-up to gh-2841.
The idea is by @josef-ptk.