Alex Herbert created RNG-128:
--------------------------------

             Summary: UnitBallSampler
                 Key: RNG-128
                 URL: https://issues.apache.org/jira/browse/RNG-128
             Project: Commons RNG
          Issue Type: Improvement
          Components: sampling
            Reporter: Alex Herbert


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|https://mathworld.wolfram.com/BallPointPicking.html]
 [Disk Point Picking|https://mathworld.wolfram.com/DiskPointPicking.html]

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:
{code:java}
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) {
        // ...
    }
}
{code}
The UnitSphereSampler sample method is named {{nextVector}}. The corresponding 
method here could be:
 * next
 * nextVector
 * nextCoordinate
 * nextPoint
 * sample
 * ...



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

Reply via email to