You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2021/05/07 19:52:19 UTC

[commons-rng] branch master updated: Javadoc: Use the same description for all shape samplers.

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git


The following commit(s) were added to refs/heads/master by this push:
     new 838295a  Javadoc: Use the same description for all shape samplers.
838295a is described below

commit 838295ae40caf488f2ae47428666d5884626395d
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri May 7 20:52:15 2021 +0100

    Javadoc: Use the same description for all shape samplers.
    
    Add the javadoc 'uniformly distributed' to the shape samplers.
    
    Add the supported number of dimensions.
    
    Use the same description for the supplied RNG.
---
 .../java/org/apache/commons/rng/sampling/shape/BoxSampler.java | 10 ++++++----
 .../org/apache/commons/rng/sampling/shape/LineSampler.java     |  6 +++---
 .../org/apache/commons/rng/sampling/shape/TriangleSampler.java |  6 +++---
 .../org/apache/commons/rng/sampling/shape/UnitBallSampler.java |  6 ++++--
 4 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/BoxSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/BoxSampler.java
index 227fad6..a6b2390 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/BoxSampler.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/BoxSampler.java
@@ -212,7 +212,7 @@ public abstract class BoxSampler implements SharedStateSampler<BoxSampler> {
     }
 
     /**
-     * @return a random Cartesian point within the box.
+     * @return a random Cartesian coordinate within the box.
      */
     public abstract double[] sample();
 
@@ -230,11 +230,13 @@ public abstract class BoxSampler implements SharedStateSampler<BoxSampler> {
 
     /**
      * Create a box sampler with bounds {@code a} and {@code b}.
-     * Points are returned within the box defined by the bounds.
+     * Sampled points are uniformly distributed within the box defined by the bounds.
      *
-     * <p>Sampling is supported in dimensions of 2 or above.
+     * <p>Sampling is supported in dimensions of 2 or above. Single dimension sampling
+     * can be performed using a {@link LineSampler}.
      *
-     * <p>There is no requirement that {@code a <= b}.
+     * <p>Note: There is no requirement that {@code a <= b}. The samples will be uniformly
+     * distributed in the range {@code a} to {@code b} for each dimension.
      *
      * @param a Bound a.
      * @param b Bound b.
diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/LineSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/LineSampler.java
index b30297f..f2a6efb 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/LineSampler.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/LineSampler.java
@@ -21,7 +21,7 @@ import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.sampling.SharedStateSampler;
 
 /**
- * Generate points on a line.
+ * Generate points uniformly distributed on a line.
  *
  * <p>Sampling uses:</p>
  *
@@ -259,7 +259,7 @@ public abstract class LineSampler implements SharedStateSampler<LineSampler> {
     }
 
     /**
-     * @return a random Cartesian point on the line.
+     * @return a random Cartesian coordinate on the line.
      */
     public double[] sample() {
         final double u = rng.nextDouble();
@@ -282,7 +282,7 @@ public abstract class LineSampler implements SharedStateSampler<LineSampler> {
 
     /**
      * Create a line sampler with vertices {@code a} and {@code b}.
-     * Points are returned on the line segment {@code ab}.
+     * Sampled points are uniformly distributed on the line segment {@code ab}.
      *
      * <p>Sampling is supported in dimensions of 1 or above.
      *
diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/TriangleSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/TriangleSampler.java
index 77c25f1..31868a2 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/TriangleSampler.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/TriangleSampler.java
@@ -22,7 +22,7 @@ import org.apache.commons.rng.sampling.SharedStateSampler;
 
 /**
  * Generate points <a href="https://mathworld.wolfram.com/TrianglePointPicking.html">
- * inside a triangle</a>.
+ * uniformly distributed within a triangle</a>.
  *
  * <ul>
  *  <li>
@@ -271,7 +271,7 @@ public abstract class TriangleSampler implements SharedStateSampler<TriangleSamp
     }
 
     /**
-     * @return a random Cartesian point inside the triangle.
+     * @return a random Cartesian coordinate within the triangle.
      */
     public double[] sample() {
         final double s = rng.nextDouble();
@@ -306,7 +306,7 @@ public abstract class TriangleSampler implements SharedStateSampler<TriangleSamp
 
     /**
      * Create a triangle sampler with vertices {@code a}, {@code b} and {@code c}.
-     * Points are returned within the triangle.
+     * Sampled points are uniformly distributed within the triangle.
      *
      * <p>Sampling is supported in dimensions of 2 or above. Samples will lie in the
      * plane (2D Euclidean space) defined by using the three triangle vertices to
diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/UnitBallSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/UnitBallSampler.java
index f6356bb..8551173 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/UnitBallSampler.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/shape/UnitBallSampler.java
@@ -200,10 +200,12 @@ public abstract class UnitBallSampler implements SharedStateSampler<UnitBallSamp
 
     /**
      * Create a unit n-ball sampler for the given dimension.
+     * Sampled points are uniformly distributed within the unit n-ball.
+     *
+     * <p>Sampling is supported in dimensions of 1 or above.
      *
      * @param dimension Space dimension.
-     * @param rng Generator for the individual components of the coordinates. A shallow
-     * copy will be stored in this instance.
+     * @param rng Source of randomness.
      * @return the sampler
      * @throws IllegalArgumentException If {@code dimension <= 0}
      */