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/08/10 12:08:46 UTC

[commons-rng] 01/03: Update class javadoc

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

commit 86ac50d36d6661fcd5b304fe0fb30e2e1c0ce777
Author: aherbert <ah...@apache.org>
AuthorDate: Mon Aug 9 22:22:24 2021 +0100

    Update class javadoc
---
 .../rng/sampling/distribution/ZigguratSampler.java        | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratSampler.java
index 297e495..cd90de7 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratSampler.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratSampler.java
@@ -32,16 +32,21 @@ import org.apache.commons.rng.UniformRandomProvider;
  *
  * <p>Note: The algorithm is a modification of the
  * {@link ZigguratNormalizedGaussianSampler Marsaglia and Tsang "Ziggurat" method}.
- * The modification improves performance of the rejection method used to generate
- * samples at the edge of the ziggurat; this is the part of the area under the
- * distribution PDF that cannot be represented using rectangles of the stepped ziggurat,
- * e.g. area A:
+ * The modification improves performance by:
+ * <ol>
+ * <li>Creating layers of the ziggurat entirely inside the probability density function (area B);
+ * this allows the majority of samples to be obtained without checking if the value is in the
+ * region of the ziggurat layer that requires a rejection test.
+ * <li>For samples not within the main ziggurat (area A) alias sampling is used to choose a
+ * layer and rejection of points above the PDF is accelerated using precomputation of
+ * triangle regions entirely below or above the curve.
+ * </ol>
  *
  * <pre>
  *           \
  * ----------+\
  *           | \
- *           |A \
+ *    B      |A \
  * -------------+\
  *              | \
  * </pre>