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

UnitBallSampler

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Implemented
    • None
    • 1.4
    • sampling
    • None

    Description

      The UnitSphereSampler can generate isotropically distributed coordinates on the surface of a hypersphere of a given dimension.

      I propose to create a UnitBallSampler to generate isotropically distributed coordinates within a hypersphere of a given dimension.

      Wolfram describes a method that will work with any dimension and a method for 2 dimensions:

      Ball Point Picking
      Disk Point Picking

      It also suggests that a simple rejection method when sampling inside an n-cube of length 2 may be faster for small dimensions.

      Creating an abstract class with a factory method would allow the best performing sampler to be created for each dimension:

      public abstract class UnitBallSampler implements
              SharedStateSampler<UnitBallSampler> {
          /**
           * @return a random Cartesian coordinate within the unit n-ball.
           */
          public double[] next() {
              // ...
          }
      
          /**
           * Create a unit n-ball sampler for the given dimension.
           *
           * @param dimension Space dimension.
           * @param rng Generator for the individual components of the coordinates. 
           * A shallow copy will be stored in this instance.
           * @throws IllegalArgumentException If {@code dimension <= 0}
           */
          public static UnitBallSampler of(int dimension,
                                           UniformRandomProvider rng) {
              // ...
          }
      }
      

      The UnitSphereSampler sample method is named nextVector. The corresponding method here could be:

      • next
      • nextVector
      • nextCoordinate
      • nextPoint
      • sample
      • ...

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h