Alex Herbert created RNG-148:
--------------------------------

             Summary: UnitSphereSampler does not check for infinite length 
dimension
                 Key: RNG-148
                 URL: https://issues.apache.org/jira/browse/RNG-148
             Project: Commons RNG
          Issue Type: Bug
          Components: sampling
    Affects Versions: 1.3
            Reporter: Alex Herbert


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:
{code:java}
if (sum == 0) {
    // Zero-norm vector is discarded.
    return sample();
}
{code}
to:
{code:java}
if (sum == 0 || sum == Double.POSITIVE_INFINITY) {
    // Invalid vector is discarded.
    return sample();
}
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to