You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2021/04/13 07:48:00 UTC

[jira] [Resolved] (RNG-128) UnitBallSampler

     [ https://issues.apache.org/jira/browse/RNG-128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alex Herbert resolved RNG-128.
------------------------------
    Fix Version/s: 1.4
         Assignee: Alex Herbert
       Resolution: Implemented

In git master.

commit: c3f7dd513bff7c22b104c186044182e883ac27f7

> UnitBallSampler
> ---------------
>
>                 Key: RNG-128
>                 URL: https://issues.apache.org/jira/browse/RNG-128
>             Project: Commons RNG
>          Issue Type: Improvement
>          Components: sampling
>            Reporter: Alex Herbert
>            Assignee: Alex Herbert
>            Priority: Minor
>             Fix For: 1.4
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> 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)