Fix #5675
Merge pull request #5676 from pavlos256/fix-rng-division-by-zero

Fix #5675