Details
-
Bug
-
Status: Closed
-
Trivial
-
Resolution: Not A Problem
-
1.3
-
None
-
None
Description
The UnitSphereSampler does not check the vector to be normalised has infinite length.
A check is already made for zero length (see RNG-55) since the underlying Gaussian sampler can return zero values. A check should also be made for infinite length. The normalisation is only valid if the sum is a finite positive value.
The code can be fixed by changing:
if (sum == 0) { // Zero-norm vector is discarded. return sample(); }
to:
if (sum == 0 || sum == Double.POSITIVE_INFINITY) { // Invalid vector is discarded. return sample(); }