Fix nearly zero division

fixes #3722
- separate "reset zero to 1.0" function from `_mean_and_std()`
- add  `_replace_nearly_value()` function
    - with` isclose()`, "nealy" zero values also replaced to 1.0
- add floating point error testcase