Uploaded image for project: 'Commons RNG'
  1. Commons RNG
  2. RNG-148

UnitSphereSampler does not check for infinite length dimension

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Not A Problem
    • 1.3
    • None
    • sampling
    • 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();
      }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              aherbert Alex Herbert
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: