(commons-rng) 01/03: RNG-187: Add benchmarks for shuffle2 variants

2024-09-02 Thread aherbert
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 6fb9ab0f15210535edfb8e5a9c773169ccb8a943
Author: Alex Herbert 
AuthorDate: Mon Sep 2 12:32:34 2024 +0100

RNG-187: Add benchmarks for shuffle2 variants

One variant has no memory allocation when generating indices. The other
accepts arguments [from, to) for the shuffle sub-range.
---
 .../jmh/sampling/ArrayShuffleBenchmark.java| 117 -
 .../jmh/sampling/ArrayShuffleBenchmarkTest.java|  47 +
 2 files changed, 159 insertions(+), 5 deletions(-)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/ArrayShuffleBenchmark.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/ArrayShuffleBenchmark.java
index 63a84652..163ce6b1 100644
--- 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/ArrayShuffleBenchmark.java
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/ArrayShuffleBenchmark.java
@@ -155,7 +155,10 @@ public class ArrayShuffleBenchmark {
 @Param({"shuffle1",
 // Effectively the same speed as shuffle1
 //"shuffle1a",
-"shuffle2", "shuffle3", "shuffle4"})
+"shuffle2", "shuffle3", "shuffle4",
+// Effectively the same speed as shuffle2; the range method is 
marginally slower
+//"shuffle2a", "shuffle2range",
+})
 private String method;
 
 /** Shuffle function. */
@@ -181,6 +184,10 @@ public class ArrayShuffleBenchmark {
 fun = ArrayShuffleBenchmark::shuffle1a;
 } else if ("shuffle2".equals(method)) {
 fun = ArrayShuffleBenchmark::shuffle2;
+} else if ("shuffle2a".equals(method)) {
+fun = ArrayShuffleBenchmark::shuffle2a;
+} else if ("shuffle2range".equals(method)) {
+fun = (rng, a) -> ArrayShuffleBenchmark.shuffle2(rng, a, 0, 
a.length);
 } else if ("shuffle3".equals(method)) {
 fun = ArrayShuffleBenchmark::shuffle3;
 } else if ("shuffle4".equals(method)) {
@@ -239,7 +246,7 @@ public class ArrayShuffleBenchmark {
 long l = m & 0xL;
 if (l < n) {
 // 2^32 % n
-final long t = POW_32 % n;
+final final long t = POW_32 % n;
 while (l < t) {
 m = (source.nextInt() & 0xL) * n;
 l = m & 0xL;
@@ -290,7 +297,7 @@ public class ArrayShuffleBenchmark {
 productBound[0] = bound;
 if (l < bound) {
 // 2^32 % bound
-long t = POW_32 % bound;
+final long t = POW_32 % bound;
 while (l < t) {
 m = (rng.nextInt() & MASK_32) * range1;
 r1 = m;
@@ -331,6 +338,106 @@ public class ArrayShuffleBenchmark {
 return array;
 }
 
+/**
+ * Shuffles the entries of the given array.
+ *
+ * @param rng Source of randomness.
+ * @param array Array whose entries will be shuffled (in-place).
+ * @param from Lower-bound (inclusive) of the sub-range.
+ * @param to Upper-bound (exclusive) of the sub-range.
+ * @return a reference to the given array
+ */
+static int[] shuffle2(UniformRandomProvider rng, int[] array, int from, 
int to) {
+int i = to - from;
+// The threshold provided in the Brackett-Rozinsky and Lemire paper
+// is the power of 2 below 20724. Note that the product 2^15*2^15
+// is representable using signed integers.
+for (; i > POW_15; i--) {
+swap(array, from + i - 1, from + rng.nextInt(i));
+}
+// Batches of 2 for sizes up to 2^15 elements
+final int[] productBound = {i * (i - 1)};
+for (; i > 1; i -= 2) {
+final int[] indices = randomBounded2(i, i - 1, productBound, rng);
+final int index1 = indices[0];
+final int index2 = indices[1];
+swap(array, from + i - 1, from + index1);
+swap(array, from + i - 2, from + index2);
+}
+return array;
+}
+
+/**
+ * Return two random values in {@code [0, range1)} and {@code [0, 
range2)}. The
+ * product bound is used for the reject algorithm. See Brackett-Rozinsky 
and Lemire.
+ *
+ * The product bound can be any positive integer {@code >= 
range1*range2}.
+ * It may be updated to become {@code range1*range2}.
+ *
+ * @param range1 Range 1.
+ *

(commons-rng) 03/03: Delegate to ArraySampler for shuffle

2024-09-02 Thread aherbert
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 88f7f97a9a174ae6d6ea3dc3a629d1834fb3aec3
Author: Alex Herbert 
AuthorDate: Mon Sep 2 14:34:57 2024 +0100

Delegate to ArraySampler for shuffle
---
 .../apache/commons/rng/sampling/ArraySampler.java  | 42 ++
 .../apache/commons/rng/sampling/ListSampler.java   | 35 ++
 .../commons/rng/sampling/PermutationSampler.java   | 21 +++
 .../commons/rng/sampling/SubsetSamplerUtils.java   |  2 +-
 4 files changed, 50 insertions(+), 50 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ArraySampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ArraySampler.java
index 9be2de44..86886705 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ArraySampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ArraySampler.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.rng.sampling;
 
+import java.util.List;
 import org.apache.commons.rng.UniformRandomProvider;
 
 /**
@@ -268,6 +269,34 @@ public final class ArraySampler {
 return array;
 }
 
+/**
+ * Shuffles the entries of the given list.
+ *
+ * Note: This method is intentionally package-private.
+ *
+ * This method exists to allow the shuffle performed by the {@link 
ListSampler} to
+ * match the {@link PermutationSampler} and {@link ArraySampler}.
+ *
+ * @param  Type of the items.
+ * @param rng Source of randomness.
+ * @param array Array whose entries will be shuffled (in-place).
+ */
+static  void shuffle(UniformRandomProvider rng, List array) {
+int i = array.size();
+for (; i > BATCH_2; --i) {
+swap(array, i - 1, rng.nextInt(i));
+}
+// Batches of 2
+final int[] productBound = {i * (i - 1)};
+for (; i > 1; i -= 2) {
+final int[] indices = randomBounded2(i, i - 1, productBound, rng);
+final int index1 = indices[0];
+final int index2 = indices[1];
+swap(array, i - 1, index1);
+swap(array, i - 2, index2);
+}
+}
+
 /**
  * Shuffles the entries of the given array in the range {@code [from, to)}.
  *
@@ -629,6 +658,19 @@ public final class ArraySampler {
 array[j] = tmp;
 }
 
+/**
+ * Swaps the two specified elements in the list.
+ *
+ * @param  Type of the list items.
+ * @param list List.
+ * @param i First index.
+ * @param j Second index.
+ */
+private static  void swap(List list, int i, int j) {
+final T tmp = list.get(i);
+list.set(i, list.get(j));
+list.set(j, tmp);
+}
 
 /**
  * Return two random values in {@code [0, range1)} and {@code [0, 
range2)}. The
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ListSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ListSampler.java
index 638b66d7..9d7a860c 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ListSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ListSampler.java
@@ -98,15 +98,11 @@ public final class ListSampler {
List list) {
 if (list instanceof RandomAccess || list.size() < 
RANDOM_ACCESS_SIZE_THRESHOLD) {
 // Shuffle list in-place
-for (int i = list.size(); i > 1; i--) {
-swap(list, i - 1, rng.nextInt(i));
-}
+ArraySampler.shuffle(rng, list);
 } else {
 // Shuffle as an array
 final Object[] array = list.toArray();
-for (int i = array.length; i > 1; i--) {
-swap(array, i - 1, rng.nextInt(i));
-}
+ArraySampler.shuffle(rng, array);
 
 // Copy back. Use raw types.
 final ListIterator it = list.listIterator();
@@ -150,31 +146,4 @@ public final class ListSampler {
 shuffle(rng, list.subList(start, list.size()));
 }
 }
-
-/**
- * Swaps the two specified elements in the list.
- *
- * @param  Type of the list items.
- * @param list List.
- * @param i First index.
- * @param j Second index.
- */
-private static  void swap(List list, int i, int j) {
-final T tmp = list.get(i);
-list.set(i, list.get(j));
-list.set(j, tmp);
-}
-
-/**
- * Swaps the two specified elements in the array.
- *
- * @param array Array.
- * @param i First index.
- * @param j Second index.
- */
-private static void swap(Object[] array, int i, int j) {
-final Object tmp = array[i];
-array[i] = array[j];
-

(commons-rng) branch master updated: Remove repeated modifier

2024-09-02 Thread aherbert
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 a61f9e15 Remove repeated modifier
a61f9e15 is described below

commit a61f9e15b20ef18d21253c6c2a8e2c0d591a3f89
Author: Alex Herbert 
AuthorDate: Mon Sep 2 23:32:50 2024 +0100

Remove repeated modifier
---
 .../apache/commons/rng/examples/jmh/sampling/ArrayShuffleBenchmark.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/ArrayShuffleBenchmark.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/ArrayShuffleBenchmark.java
index 163ce6b1..a4937ac1 100644
--- 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/ArrayShuffleBenchmark.java
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/ArrayShuffleBenchmark.java
@@ -246,7 +246,7 @@ public class ArrayShuffleBenchmark {
 long l = m & 0xL;
 if (l < n) {
 // 2^32 % n
-final final long t = POW_32 % n;
+final long t = POW_32 % n;
 while (l < t) {
 m = (source.nextInt() & 0xL) * n;
 l = m & 0xL;



(commons-rng) 02/03: RNG-187: Use batched index generation in array shuffle

2024-09-02 Thread aherbert
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 61f982c4011fa18a88354224e07ae81240c2b815
Author: Alex Herbert 
AuthorDate: Mon Sep 2 13:26:32 2024 +0100

RNG-187: Use batched index generation in array shuffle
---
 .../apache/commons/rng/sampling/ArraySampler.java  | 287 +++--
 .../commons/rng/sampling/ArraySamplerTest.java | 181 -
 src/changes/changes.xml|   3 +
 3 files changed, 441 insertions(+), 30 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ArraySampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ArraySampler.java
index e2772ce4..9be2de44 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ArraySampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ArraySampler.java
@@ -25,9 +25,29 @@ import org.apache.commons.rng.UniformRandomProvider;
  * 
href="https://en.wikipedia.org/wiki/Fisher-Yates_shuffle#The_modern_algorithm";>
  * Fisher-Yates algorithm.
  *
+ * Small ranges use batched random integer generation to increase 
performance.
+ *
+ * 
+ * Nevin Brackett-Rozinsky, Daniel Lemire,
+ * Batched Ranged Random Integer Generation, Software: Practice and Experience 
(to appear)
+ * https://arxiv.org/abs/2408.06213";>arXiv:2408.06213M
+ * 
+ *
  * @since 1.6
  */
 public final class ArraySampler {
+/** Mask the lower 32-bit of a long. */
+private static final long MASK_32 = 0xL;
+/** 2^32. Used for the bounded random algorithm. This is required as the 
original
+ * method used (-bound % bound) for (2^L % bound) which only works for 
unsigned integer
+ * modulus. */
+private static final long POW_32 = 1L << 32;
+/** Length threshold to sample 2 integers from a random 32-bit value.
+ * The threshold provided in the Brackett-Rozinsky and Lemire paper
+ * is the power of 2 below 20724. Note that the product 2^15*2^15
+ * is representable using signed integers. */
+private static final int BATCH_2 = 1 << 15;
+
 /** Class contains only static methods. */
 private ArraySampler() {}
 
@@ -39,9 +59,19 @@ public final class ArraySampler {
  * @return a reference to the given array
  */
 public static boolean[] shuffle(UniformRandomProvider rng, boolean[] 
array) {
-for (int i = array.length; i > 1; i--) {
+int i = array.length;
+for (; i > BATCH_2; --i) {
 swap(array, i - 1, rng.nextInt(i));
 }
+// Batches of 2
+final int[] productBound = {i * (i - 1)};
+for (; i > 1; i -= 2) {
+final int[] indices = randomBounded2(i, i - 1, productBound, rng);
+final int index1 = indices[0];
+final int index2 = indices[1];
+swap(array, i - 1, index1);
+swap(array, i - 2, index2);
+}
 return array;
 }
 
@@ -53,9 +83,19 @@ public final class ArraySampler {
  * @return a reference to the given array
  */
 public static byte[] shuffle(UniformRandomProvider rng, byte[] array) {
-for (int i = array.length; i > 1; i--) {
+int i = array.length;
+for (; i > BATCH_2; --i) {
 swap(array, i - 1, rng.nextInt(i));
 }
+// Batches of 2
+final int[] productBound = {i * (i - 1)};
+for (; i > 1; i -= 2) {
+final int[] indices = randomBounded2(i, i - 1, productBound, rng);
+final int index1 = indices[0];
+final int index2 = indices[1];
+swap(array, i - 1, index1);
+swap(array, i - 2, index2);
+}
 return array;
 }
 
@@ -67,9 +107,19 @@ public final class ArraySampler {
  * @return a reference to the given array
  */
 public static char[] shuffle(UniformRandomProvider rng, char[] array) {
-for (int i = array.length; i > 1; i--) {
+int i = array.length;
+for (; i > BATCH_2; --i) {
 swap(array, i - 1, rng.nextInt(i));
 }
+// Batches of 2
+final int[] productBound = {i * (i - 1)};
+for (; i > 1; i -= 2) {
+final int[] indices = randomBounded2(i, i - 1, productBound, rng);
+final int index1 = indices[0];
+final int index2 = indices[1];
+swap(array, i - 1, index1);
+swap(array, i - 2, index2);
+}
 return array;
 }
 
@@ -81,9 +131,19 @@ public final class ArraySampler {
  * @return a reference to the given array
  */
 public static double[] shuffle(UniformRandomProvider rng, double[] array) {
-for (int i = array.length; i > 1; i--) {
+int i = array.length;
+for (; i 

(commons-rng) branch master updated (e37e90e4 -> 88f7f97a)

2024-09-02 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from e37e90e4 RNG-187: Add benchmarks for shuffle without index checks
 new 6fb9ab0f RNG-187: Add benchmarks for shuffle2 variants
 new 61f982c4 RNG-187: Use batched index generation in array shuffle
 new 88f7f97a Delegate to ArraySampler for shuffle

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../jmh/sampling/ArrayShuffleBenchmark.java| 117 +++-
 .../jmh/sampling/ArrayShuffleBenchmarkTest.java|  47 +++
 .../apache/commons/rng/sampling/ArraySampler.java  | 329 +++--
 .../apache/commons/rng/sampling/ListSampler.java   |  35 +--
 .../commons/rng/sampling/PermutationSampler.java   |  21 +-
 .../commons/rng/sampling/SubsetSamplerUtils.java   |   2 +-
 .../commons/rng/sampling/ArraySamplerTest.java | 181 +++-
 src/changes/changes.xml|   3 +
 8 files changed, 650 insertions(+), 85 deletions(-)



[commons-rng] 07/17: Formatted code and javadoc

2019-02-14 Thread aherbert
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 2b24bf79a3bb119cb0389771971b32e2a5a796e4
Author: aherbert 
AuthorDate: Thu Feb 14 12:26:03 2019 +

Formatted code and javadoc
---
 .../distribution/GeometricSamplersPerformance.java |  5 ++--
 .../sampling/distribution/GeometricSampler.java| 14 +
 .../distribution/GeometricSamplerTest.java | 33 --
 3 files changed, 29 insertions(+), 23 deletions(-)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/distribution/GeometricSamplersPerformance.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/distribution/GeometricSamplersPerformance.java
index 60e86ad..bf3cdf9 100644
--- 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/distribution/GeometricSamplersPerformance.java
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/distribution/GeometricSamplersPerformance.java
@@ -134,8 +134,9 @@ public class GeometricSamplersPerformance {
 // ---
 // Note: if cumulativeProbability == 0 then log1p(-0) is zero and 
the result
 // after the range check is 0.
-// Note: if cumulativeProbability == 1 then log1p(-1) is negative 
infinity, the result of
-// the divide is positive infinity and the result after the range 
check is Integer.MAX_VALUE.
+// Note: if cumulativeProbability == 1 then log1p(-1) is negative 
infinity, the result
+// of the divide is positive infinity and the result after the 
range check is
+// Integer.MAX_VALUE.
 return Math.max(0, (int) 
Math.ceil(Math.log1p(-cumulativeProbability) / log1mProbabilityOfSuccess - 1));
 }
 }
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
index ba62ac4..2197d4c 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
@@ -78,7 +78,8 @@ public class GeometricSampler implements DiscreteSampler {
 
 /**
  * @param rng Generator of uniformly distributed random numbers
- * @param probabilityOfSuccess The probability of success (must be 
{@code 0 1) {
 throw new IllegalArgumentException(
-"Probability of success must be in the range [0 < p <= 1]: " + 
probabilityOfSuccess);
+"Probability of success (p) must be in the range [0 < p <= 1]: 
"
++ probabilityOfSuccess);
 }
 delegate = probabilityOfSuccess == 1 ?
 GeometricP1Sampler.INSTANCE :
@@ -132,8 +134,8 @@ public class GeometricSampler implements DiscreteSampler {
 /**
  * Create a sample from a geometric distribution.
  *
- * The sample will take the values in the set {@code [0, 1, 2, ...]}, 
equivalent to the number of
- * failures before the first success.
+ * The sample will take the values in the set {@code [0, 1, 2, ...]}, 
equivalent to the
+ * number of failures before the first success.
  */
 @Override
 public int sample() {
diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
index 00f1000..c3267bf 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.rng.sampling.distribution;
 
 import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.core.source64.SplitMix64;
 import org.apache.commons.rng.simple.RandomSource;
 import org.junit.Assert;
 import org.junit.Test;
@@ -26,8 +27,8 @@ import org.junit.Test;
  */
 public class GeometricSamplerTest {
 /**
- * Test the edge case where the probability of success is 1. This is a 
valid geometric distribution
- * where the sample should always be 0.
+ * Test the edge case where the probability of success is 1. This is a 
valid geometric
+ * distribution where the sample should always be 0.
  */
 @Test
 public void testProbabilityOfSuccessIsOneGeneratesZeroForSamples() {
@@ -45,18 +46,20 @@ public class GeometricSamplerTest {
  */
 @Test
 public void testProbabilityOfSuccessIsOneSa

[commons-rng] 02/17: RNG-68: Fixed formatting

2019-02-14 Thread aherbert
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 251dc2eec99c37b3ad3da8b429568a29f77ca6e9
Author: aherbert 
AuthorDate: Mon Jan 28 10:39:16 2019 +

RNG-68: Fixed formatting
---
 .../distribution/AhrensDieterMarsagliaTsangGammaSampler.java| 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
index ab2b176..42a50e4 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
@@ -115,7 +115,6 @@ public class AhrensDieterMarsagliaTsangGammaSampler
 
 if (p <= 1) {
 // Step 2:
-
 final double x = Math.pow(p, oneOverTheta);
 final double u2 = rng.nextDouble();
 
@@ -127,7 +126,6 @@ public class AhrensDieterMarsagliaTsangGammaSampler
 }
 
 // Step 3:
-
 final double x = -Math.log((bGSOptim - p) * oneOverTheta);
 final double u2 = rng.nextDouble();
 
@@ -162,8 +160,8 @@ public class AhrensDieterMarsagliaTsangGammaSampler
  * @param theta Theta scale parameter of the distribution.
  */
 LargeThetaAhrensDieterMarsagliaTsangGammaSampler(UniformRandomProvider 
rng,
- double alpha,
- double theta) {
+ double alpha,
+ double theta) {
 super(rng, alpha, theta);
 gaussian = new ZigguratNormalizedGaussianSampler(rng);
 dOptim = theta - ONE_THIRD;



[commons-rng] 06/17: Merge branch 'improvement-RNG-69' of https://github.com/aherbert/commons-rng into improvement-RNG-69

2019-02-14 Thread aherbert
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 e18e0fbcb852cd74cb8106ad513773f5d4b5ab01
Merge: c547833 77cfd26
Author: aherbert 
AuthorDate: Thu Feb 14 12:09:44 2019 +

Merge branch 'improvement-RNG-69' of
https://github.com/aherbert/commons-rng into improvement-RNG-69

 .../distribution/GeometricSamplersPerformance.java | 190 +
 .../jmh/distribution/SamplersPerformance.java  |  19 ++-
 .../sampling/distribution/GeometricSampler.java| 148 
 .../distribution/DiscreteSamplersList.java |   4 +
 .../distribution/GeometricSamplerTest.java |  91 ++
 5 files changed, 448 insertions(+), 4 deletions(-)

diff --cc 
commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/DiscreteSamplersList.java
index 21cd20b,3e93c86..b9e1bc0
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/DiscreteSamplersList.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/DiscreteSamplersList.java
@@@ -49,9 -46,13 +49,13 @@@ public class DiscreteSamplersList 
  
  // Geometric ("inverse method").
  final double probSuccessGeometric = 0.21;
 -add(LIST, new 
org.apache.commons.math3.distribution.GeometricDistribution(null, 
probSuccessGeometric),
 +add(LIST, new 
org.apache.commons.math3.distribution.GeometricDistribution(rng, 
probSuccessGeometric),
  MathArrays.sequence(10, 0, 1),
  RandomSource.create(RandomSource.ISAAC));
+ // Geometric.
 -add(LIST, new 
org.apache.commons.math3.distribution.GeometricDistribution(null, 
probSuccessGeometric),
++add(LIST, new 
org.apache.commons.math3.distribution.GeometricDistribution(rng, 
probSuccessGeometric),
+ MathArrays.sequence(10, 0, 1),
+ new 
GeometricSampler(RandomSource.create(RandomSource.XOR_SHIFT_1024_S), 
probSuccessGeometric));
  
  // Hypergeometric ("inverse method").
  final int popSizeHyper = 34;



[commons-rng] 08/17: Track changes

2019-02-14 Thread aherbert
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 1a935898f60569314313defb5a1c022d5325d45b
Author: aherbert 
AuthorDate: Thu Feb 14 12:27:51 2019 +

Track changes
---
 src/changes/changes.xml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2610b5b..8ddab98 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,7 +75,9 @@ re-run tests that fail, and pass the build if they succeed
 within the allotted number of reruns (the test will be marked
 as 'flaky' in the report).
 ">
-
+  
+New "GeometricSampler" class.
+  
 
 
 



[commons-rng] 01/17: RNG-68: Add private classes for each algorithm

2019-02-14 Thread aherbert
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 ad8739b2290ae8ea34954b08fd496c6ca07c3b33
Author: aherbert 
AuthorDate: Mon Jan 28 10:33:09 2019 +

RNG-68: Add private classes for each algorithm
---
 .../AhrensDieterMarsagliaTsangGammaSampler.java| 174 +++--
 1 file changed, 123 insertions(+), 51 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
index d34902d..ab2b176 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
@@ -44,48 +44,68 @@ import org.apache.commons.rng.UniformRandomProvider;
 public class AhrensDieterMarsagliaTsangGammaSampler
 extends SamplerBase
 implements ContinuousSampler {
-/** 1/3 */
-private static final double ONE_THIRD = 1d / 3;
-/** The shape parameter. */
-private final double theta;
-/** The alpha parameter. */
-private final double alpha;
-/** Inverse of "theta". */
-private final double oneOverTheta;
-/** Optimization (see code). */
-private final double bGSOptim;
-/** Optimization (see code). */
-private final double dOptim;
-/** Optimization (see code). */
-private final double cOptim;
-/** Gaussian sampling. */
-private final NormalizedGaussianSampler gaussian;
-/** Underlying source of randomness. */
-private final UniformRandomProvider rng;
+/** The appropriate gamma sampler for the parameters. */
+private final ContinuousSampler delegate;
 
 /**
- * @param rng Generator of uniformly distributed random numbers.
- * @param alpha Alpha parameter of the distribution.
- * @param theta Theta parameter of the distribution.
+ * Base class for a sampler from the Gamma distribution.
  */
-public AhrensDieterMarsagliaTsangGammaSampler(UniformRandomProvider rng,
-  double alpha,
-  double theta) {
-super(null);
-this.rng = rng;
-this.alpha = alpha;
-this.theta = theta;
-gaussian = new ZigguratNormalizedGaussianSampler(rng);
-oneOverTheta = 1 / theta;
-bGSOptim = 1 + theta / Math.E;
-dOptim = theta - ONE_THIRD;
-cOptim = ONE_THIRD / Math.sqrt(dOptim);
+private abstract static class BaseAhrensDieterMarsagliaTsangGammaSampler
+implements ContinuousSampler {
+
+/** Underlying source of randomness. */
+protected final UniformRandomProvider rng;
+/** The shape parameter. */
+protected final double theta;
+/** The alpha parameter. */
+protected final double alpha;
+
+/**
+ * @param rng Generator of uniformly distributed random numbers.
+ * @param alpha Alpha shape parameter of the distribution.
+ * @param theta Theta scale parameter of the distribution.
+ */
+BaseAhrensDieterMarsagliaTsangGammaSampler(UniformRandomProvider rng,
+   double alpha,
+   double theta) {
+this.rng = rng;
+this.alpha = alpha;
+this.theta = theta;
+}
+
+/** {@inheritDoc} */
+@Override
+public String toString() {
+return "Ahrens-Dieter-Marsaglia-Tsang Gamma deviate [" + 
rng.toString() + "]";
+}
 }
 
-/** {@inheritDoc} */
-@Override
-public double sample() {
-if (theta < 1) {
+/**
+ * Class to sample from the Gamma distribution when {@code 0 < theta < 1}.
+ */
+private static class SmallThetaAhrensDieterMarsagliaTsangGammaSampler
+extends BaseAhrensDieterMarsagliaTsangGammaSampler {
+
+/** Inverse of "theta". */
+private final double oneOverTheta;
+/** Optimization (see code). */
+private final double bGSOptim;
+
+/**
+ * @param rng Generator of uniformly distributed random numbers.
+ * @param alpha Alpha shape parameter of the distribution.
+ * @param theta Theta scale parameter of the distribution.
+ */
+SmallThetaAhrensDieterMarsagliaTsangGammaSampler(UniformRandomProvider 
rng,
+ double alpha,
+ double theta) {
+super(rng, alpha, theta);
+  

[commons-rng] 09/17: Merge branch 'improvement-RNG-69'

2019-02-14 Thread aherbert
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 9fcc3c84f0a16cbc12836a01a3c6fa766c08c784
Merge: c547833 1a93589
Author: aherbert 
AuthorDate: Thu Feb 14 12:28:28 2019 +

Merge branch 'improvement-RNG-69'

Closes #19

 .../distribution/GeometricSamplersPerformance.java | 191 +
 .../jmh/distribution/SamplersPerformance.java  |  19 +-
 .../sampling/distribution/GeometricSampler.java| 150 
 .../distribution/DiscreteSamplersList.java |   4 +
 .../distribution/GeometricSamplerTest.java |  94 ++
 src/changes/changes.xml|   4 +-
 6 files changed, 457 insertions(+), 5 deletions(-)



[commons-rng] 12/17: Merge branch 'improvement-RNG-67'

2019-02-14 Thread aherbert
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 6e7e5f4a35b4173a4ea5a2629bd8a1e17dd43ba1
Merge: 9fcc3c8 d301d58
Author: aherbert 
AuthorDate: Thu Feb 14 12:38:15 2019 +

Merge branch 'improvement-RNG-67'

Closes #18

 commons-rng-examples/examples-stress/pom.xml   | 45 +
 .../rng/examples/stress/IntGeneratorsList.java | 49 ++
 .../rng/examples/stress/LongGeneratorsList.java| 49 ++
 .../examples-stress/stress_test.md | 76 ++
 src/changes/changes.xml|  4 +-
 5 files changed, 222 insertions(+), 1 deletion(-)



[commons-rng] 05/17: RNG-69: Updated code formatting and GeometricSampler javadoc

2019-02-14 Thread aherbert
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 77cfd26485c126c6245a9ae70a27000dbad8492f
Author: aherbert 
AuthorDate: Tue Jan 29 12:29:38 2019 +

RNG-69: Updated code formatting and GeometricSampler javadoc
---
 .../rng/sampling/distribution/GeometricSampler.java| 18 +++---
 .../sampling/distribution/DiscreteSamplersList.java|  2 +-
 .../sampling/distribution/GeometricSamplerTest.java|  2 +-
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
index ab2a6c4..ba62ac4 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
@@ -25,16 +25,20 @@ import org.apache.commons.rng.UniformRandomProvider;
  * This distribution samples the number of failures before the first 
success taking values in the
  * set {@code [0, 1, 2, ...]}.
  *
- * The sample is computed using a related an exponential distribution. If X 
is an exponentially
- * distributed random variable with parameter λ, then Y = floor(X) is a 
geometrically distributed
- * random variable with parameter p = 1 − e−λ, with {@code p} the 
probability of success.
+ * The sample is computed using a related an exponential distribution. If 
{@code X} is an
+ * exponentially distributed random variable with parameter λ, then {@code Y = 
floor(X)} is a
+ * geometrically distributed random variable with parameter p = 1 − 
e−λ, with {@code p}
+ * the probability of success.
  *
- * Note: As the probability of success ({@code p}) tends towards zero the 
mean of the
+ * This sampler outperforms using the {@link 
InverseTransformDiscreteSampler} with an appropriate
+ * Geometric inverse cumulative probability function.
+ *
+ * Usage note: As the probability of success ({@code p}) tends towards zero 
the mean of the
  * distribution ({@code (1-p)/p}) tends towards infinity and due to the use of 
{@code int} for the
- * sample this results in truncation of the distribution.
+ * sample this can result in truncation of the distribution.
  *
  * @see https://en.wikipedia.org/wiki/Geometric_distribution#Related_distributions";>geometric
+ * 
href="https://en.wikipedia.org/wiki/Geometric_distribution#Related_distributions";>Geometric
  * distribution - related distributions
  *
  * @since 1.3
@@ -118,7 +122,7 @@ public class GeometricSampler implements DiscreteSampler {
 public GeometricSampler(UniformRandomProvider rng, double 
probabilityOfSuccess) {
 if (probabilityOfSuccess <= 0 || probabilityOfSuccess > 1) {
 throw new IllegalArgumentException(
-"Probability of success must be in the range [0 < p <= 1]: 
" + probabilityOfSuccess);
+"Probability of success must be in the range [0 < p <= 1]: " + 
probabilityOfSuccess);
 }
 delegate = probabilityOfSuccess == 1 ?
 GeometricP1Sampler.INSTANCE :
diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/DiscreteSamplersList.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/DiscreteSamplersList.java
index 3f9adb8..3e93c86 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/DiscreteSamplersList.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/DiscreteSamplersList.java
@@ -50,7 +50,7 @@ public class DiscreteSamplersList {
 MathArrays.sequence(10, 0, 1),
 RandomSource.create(RandomSource.ISAAC));
 // Geometric.
-add(LIST, new 
org.apache.commons.math3.distribution.GeometricDistribution(probSuccessGeometric),
+add(LIST, new 
org.apache.commons.math3.distribution.GeometricDistribution(null, 
probSuccessGeometric),
 MathArrays.sequence(10, 0, 1),
 new 
GeometricSampler(RandomSource.create(RandomSource.XOR_SHIFT_1024_S), 
probSuccessGeometric));
 
diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
index 8c5a39e..00f1000 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
@@ -65,7 +65,7 @@ public class GeometricSamplerTest {

[commons-rng] 10/17: Merge branch 'improvement-RNG-67' of https://github.com/aherbert/commons-rng into improvement-RNG-67

2019-02-14 Thread aherbert
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 25467f51aeec111876f2adddf79a3e9545a26246
Merge: 9fcc3c8 9f54e57
Author: aherbert 
AuthorDate: Thu Feb 14 12:32:12 2019 +

Merge branch 'improvement-RNG-67' of 
https://github.com/aherbert/commons-rng into improvement-RNG-67

 commons-rng-examples/examples-stress/pom.xml   | 45 +
 .../rng/examples/stress/IntGeneratorsList.java | 49 ++
 .../rng/examples/stress/LongGeneratorsList.java| 49 ++
 .../examples-stress/stress_test.md | 76 ++
 4 files changed, 219 insertions(+)



[commons-rng] 15/17: Merge branch 'improvement-RNG-68'

2019-02-14 Thread aherbert
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 1afd499226120fafe11022b310dc0e67c62345c2
Merge: 6e7e5f4 e8ca1f6
Author: aherbert 
AuthorDate: Thu Feb 14 12:50:52 2019 +

Merge branch 'improvement-RNG-68'

Closes #17

 .../AhrensDieterMarsagliaTsangGammaSampler.java| 174 +++--
 src/changes/changes.xml|   4 +
 2 files changed, 126 insertions(+), 52 deletions(-)



[commons-rng] 04/17: RNG-67: Instructions for how to build and run the examples-stress code

2019-02-14 Thread aherbert
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 9f54e579197a9c937110aff7df43dcbcd65375f5
Author: aherbert 
AuthorDate: Tue Jan 29 10:24:09 2019 +

RNG-67: Instructions for how to build and run the examples-stress code
---
 commons-rng-examples/examples-stress/pom.xml   | 45 +
 .../rng/examples/stress/IntGeneratorsList.java | 49 ++
 .../rng/examples/stress/LongGeneratorsList.java| 49 ++
 .../examples-stress/stress_test.md | 76 ++
 4 files changed, 219 insertions(+)

diff --git a/commons-rng-examples/examples-stress/pom.xml 
b/commons-rng-examples/examples-stress/pom.xml
index a7cf345..ef2bae2 100644
--- a/commons-rng-examples/examples-stress/pom.xml
+++ b/commons-rng-examples/examples-stress/pom.xml
@@ -45,6 +45,9 @@
 
org.apache.commons.rng.examples.stress
 
 ${basedir}/../..
+
+examples-stress
+
org.apache.commons.rng.examples.stress.RandomStressTester
   
 
   
@@ -59,4 +62,46 @@
 
   
 
+  
+
+  examples-stress
+  
+
+  
+org.apache.maven.plugins
+maven-shade-plugin
+
+  
+package
+
+  shade
+
+
+  ${uberjar.name}
+  
+
+  ${project.mainClass}
+
+  
+  
+
+  
+  *:*
+  
+META-INF/*.SF
+META-INF/*.DSA
+META-INF/*.RSA
+  
+
+  
+
+  
+
+  
+
+  
+
+  
+
 
diff --git 
a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/IntGeneratorsList.java
 
b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/IntGeneratorsList.java
new file mode 100644
index 000..72d15d1
--- /dev/null
+++ 
b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/IntGeneratorsList.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.examples.stress;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.core.source32.IntProvider;
+
+/**
+ * List of generators that use {@link IntProvider} as a base class.
+ */
+public class IntGeneratorsList implements Iterable {
+/** List of generators. */
+private final List list = new ArrayList<>();
+
+/**
+ * Creates list.
+ */
+public IntGeneratorsList() {
+for (UniformRandomProvider rng : new GeneratorsList()) {
+if (rng instanceof IntProvider) {
+list.add(rng);
+}
+}
+}
+
+/** {@inheritDoc} */
+@Override
+public Iterator iterator() {
+return list.iterator();
+}
+}
diff --git 
a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/LongGeneratorsList.java
 
b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/LongGeneratorsList.java
new file mode 100644
index 000..259b1bd
--- /dev/null
+++ 
b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/LongGeneratorsList.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  ht

[commons-rng] branch master updated (c547833 -> 8e1c529)

2019-02-14 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from c547833  Fixed test coverage in MersenneTwister64Test
 new edcdf9a  RNG-69: Added a Geometric sampler
 new 77cfd26  RNG-69: Updated code formatting and GeometricSampler javadoc
 new e18e0fb  Merge branch 'improvement-RNG-69' of 
https://github.com/aherbert/commons-rng into improvement-RNG-69
 new 2b24bf7  Formatted code and javadoc
 new 1a93589  Track changes
 new 9fcc3c8  Merge branch 'improvement-RNG-69'
 new 9f54e57  RNG-67: Instructions for how to build and run the 
examples-stress code
 new 25467f5  Merge branch 'improvement-RNG-67' of 
https://github.com/aherbert/commons-rng into improvement-RNG-67
 new d301d58  Track changes
 new 6e7e5f4  Merge branch 'improvement-RNG-67'
 new ad8739b  RNG-68: Add private classes for each algorithm
 new 251dc2e  RNG-68: Fixed formatting
 new b7b40cf  Merge branch 'improvement-RNG-68' of 
https://github.com/aherbert/commons-rng into improvement-RNG-68
 new e8ca1f6  Track changes.
 new 1afd499  Merge branch 'improvement-RNG-68'
 new 26cfa30  Updated checkstyle to use the latest checkstyle version (8.17)
 new 8e1c529  Fixed checkstyle violation

The 17 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../distribution/GeometricSamplersPerformance.java | 191 +
 .../jmh/distribution/SamplersPerformance.java  |  19 +-
 commons-rng-examples/examples-stress/pom.xml   |  45 +
 .../rng/examples/stress/IntGeneratorsList.java |  41 +++--
 .../rng/examples/stress/LongGeneratorsList.java|  41 +++--
 .../examples-stress/stress_test.md |  76 
 .../AhrensDieterMarsagliaTsangGammaSampler.java| 174 +--
 .../sampling/distribution/GeometricSampler.java| 150 
 .../distribution/DiscreteSamplersList.java |   4 +
 .../distribution/GeometricSamplerTest.java |  94 ++
 pom.xml| 120 +++--
 src/changes/changes.xml|  12 +-
 src/main/resources/checkstyle/checkstyle.xml   |  60 ++-
 13 files changed, 825 insertions(+), 202 deletions(-)
 create mode 100644 
commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/distribution/GeometricSamplersPerformance.java
 copy 
commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/Long2LongArray.java
 => 
commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/IntGeneratorsList.java
 (53%)
 copy 
commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/Long2LongArray.java
 => 
commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/LongGeneratorsList.java
 (53%)
 create mode 100644 commons-rng-examples/examples-stress/stress_test.md
 create mode 100644 
commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
 create mode 100644 
commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java



[commons-rng] 11/17: Track changes

2019-02-14 Thread aherbert
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 d301d58aeb51d61611ecf8cefd177ba0d2f6e870
Author: aherbert 
AuthorDate: Thu Feb 14 12:37:41 2019 +

Track changes
---
 src/changes/changes.xml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8ddab98..f9be7f0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,12 +75,14 @@ re-run tests that fail, and pass the build if they succeed
 within the allotted number of reruns (the test will be marked
 as 'flaky' in the report).
 ">
+  
+Instructions for how to build and run the examples-stress code.
+  
   
 New "GeometricSampler" class.
   
 
 
-
 

[commons-rng] 17/17: Fixed checkstyle violation

2019-02-14 Thread aherbert
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 8e1c529efc8617053cc896dd14748b70cf2c107a
Author: aherbert 
AuthorDate: Thu Feb 14 13:58:30 2019 +

Fixed checkstyle violation
---
 .../apache/commons/rng/sampling/distribution/GeometricSampler.java| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
index 2197d4c..757367d 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
@@ -123,8 +123,8 @@ public class GeometricSampler implements DiscreteSampler {
 public GeometricSampler(UniformRandomProvider rng, double 
probabilityOfSuccess) {
 if (probabilityOfSuccess <= 0 || probabilityOfSuccess > 1) {
 throw new IllegalArgumentException(
-"Probability of success (p) must be in the range [0 < p <= 1]: 
"
-+ probabilityOfSuccess);
+"Probability of success (p) must be in the range [0 < p <= 1]: 
" +
+probabilityOfSuccess);
 }
 delegate = probabilityOfSuccess == 1 ?
 GeometricP1Sampler.INSTANCE :



[commons-rng] 14/17: Track changes.

2019-02-14 Thread aherbert
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 e8ca1f613d6af0a6d694d91c6b1291c73ac98e59
Author: aherbert 
AuthorDate: Thu Feb 14 12:50:30 2019 +

Track changes.
---
 src/changes/changes.xml | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f9be7f0..94b74d0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,6 +75,10 @@ re-run tests that fail, and pass the build if they succeed
 within the allotted number of reruns (the test will be marked
 as 'flaky' in the report).
 ">
+  
+""AhrensDieterMarsagliaTsangGammaSampler": Algorithms for small and 
large theta have
+been delegated to specialised classes.
+  
   
 Instructions for how to build and run the examples-stress code.
   



[commons-rng] 13/17: Merge branch 'improvement-RNG-68' of https://github.com/aherbert/commons-rng into improvement-RNG-68

2019-02-14 Thread aherbert
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 b7b40cf39822bc33fac8ac17356ce0f01def93bc
Merge: 6e7e5f4 251dc2e
Author: aherbert 
AuthorDate: Thu Feb 14 12:39:34 2019 +

Merge branch 'improvement-RNG-68' of 
https://github.com/aherbert/commons-rng into improvement-RNG-68

 .../AhrensDieterMarsagliaTsangGammaSampler.java| 174 +++--
 1 file changed, 122 insertions(+), 52 deletions(-)



[commons-rng] 16/17: Updated checkstyle to use the latest checkstyle version (8.17)

2019-02-14 Thread aherbert
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 26cfa3022f6e8449557562272ae5bcddb7615056
Author: aherbert 
AuthorDate: Thu Feb 14 13:53:45 2019 +

Updated checkstyle to use the latest checkstyle version (8.17)

This version of checkstyle requires java 8 and so the plugin
configuration has been moved to a profile activated by JDK 1.8+.
---
 pom.xml  | 120 +++
 src/main/resources/checkstyle/checkstyle.xml |  60 +++---
 2 files changed, 78 insertions(+), 102 deletions(-)

diff --git a/pom.xml b/pom.xml
index 00a9684..36ac983 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,6 +108,7 @@
 1.6
 3.9.0
 3.0.0
+8.17
 2.7.2
 
 ${basedir}
@@ -196,20 +197,7 @@
   
 
   
-
-  
-org.apache.maven.plugins
-maven-checkstyle-plugin
-
-  
-validate
-validate
-
-  check
-
-  
-
-  
+  
   
 com.github.spotbugs
 spotbugs-maven-plugin
@@ -257,25 +245,6 @@
   
 
 
-
-
-  
-
-  org.apache.maven.plugins
-  maven-checkstyle-plugin
-  ${rng.checkstyle.version}
-  
-false
-
${rng.parent.dir}/src/main/resources/checkstyle/checkstyle.xml
-
${rng.parent.dir}/src/main/resources/checkstyle/license-header.txt
-false
-false
-NOTICE.txt,LICENSE.txt
-**/module-info.java
-  
-
-  
-
   
 
   
@@ -333,25 +302,7 @@
   
${rng.parent.dir}/src/main/resources/spotbugs/spotbugs-exclude-filter.xml
 
   
-  
-org.apache.maven.plugins
-maven-checkstyle-plugin
-${rng.checkstyle.version}
-
-  
${rng.parent.dir}/src/main/resources/checkstyle/checkstyle.xml
-  
${rng.parent.dir}/src/main/resources/checkstyle/license-header.txt
-  false
-  false
-  **/module-info.java
-
-
-  
-
-  checkstyle
-
-  
-
-  
+  
   
 maven-pmd-plugin
 ${rng.pmd.version}
@@ -567,6 +518,70 @@
 
   
 
+
+
+  jdk8-plugins
+  
+[1.8,)
+  
+  
+
+  
+org.apache.maven.plugins
+maven-checkstyle-plugin
+${rng.checkstyle.version}
+
+  
+com.puppycrawl.tools
+checkstyle
+${rng.checkstyle.dep.version}
+  
+
+
+  false
+  
${rng.parent.dir}/src/main/resources/checkstyle/checkstyle.xml
+  
${rng.parent.dir}/src/main/resources/checkstyle/license-header.txt
+  false
+  false
+  NOTICE.txt,LICENSE.txt
+  **/module-info.java
+
+
+  
+validate
+validate
+
+  check
+
+  
+
+  
+
+  
+  
+
+  
+org.apache.maven.plugins
+maven-checkstyle-plugin
+${rng.checkstyle.version}
+
+  
${rng.parent.dir}/src/main/resources/checkstyle/checkstyle.xml
+  
${rng.parent.dir}/src/main/resources/checkstyle/license-header.txt
+  false
+  false
+  **/module-info.java
+
+
+  
+
+  checkstyle
+
+  
+
+  
+
+  
+
 
 
-
-
 
 
 
@@ -137,6 +134,17 @@
 
 
 
+
+
+  
+  
+  
+
+
+  
+  
+
+
   
 
   
@@ -153,50 +161,4 @@
   
   
 
-  
-  
-
-
-
-  
-  
-
-
-
-  
-  
-
-
-
-  
-  
-
-
-
-  
-  
-
-
-
-  
-  
-
-
-
-  
-  
-
-
-
-  
-  
-
-
-
-  
-  
-
-
-  
 
-



[commons-rng] 03/17: RNG-69: Added a Geometric sampler

2019-02-14 Thread aherbert
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 edcdf9affa4648609120e5882f83facf2fb1ef05
Author: aherbert 
AuthorDate: Mon Jan 28 16:24:54 2019 +

RNG-69: Added a Geometric sampler

This outperforms using the InverseTransformDiscreteSampler with an
appropriate Geometric inverse cumulative probability function. A JMH
benchmark has been added to demonstrate the performance.
---
 .../distribution/GeometricSamplersPerformance.java | 190 +
 .../jmh/distribution/SamplersPerformance.java  |  19 ++-
 .../sampling/distribution/GeometricSampler.java| 144 
 .../distribution/DiscreteSamplersList.java |   8 +-
 .../distribution/GeometricSamplerTest.java |  91 ++
 5 files changed, 446 insertions(+), 6 deletions(-)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/distribution/GeometricSamplersPerformance.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/distribution/GeometricSamplersPerformance.java
new file mode 100644
index 000..60e86ad
--- /dev/null
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/distribution/GeometricSamplersPerformance.java
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.rng.examples.jmh.distribution;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.infra.Blackhole;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.simple.RandomSource;
+import 
org.apache.commons.rng.sampling.distribution.DiscreteInverseCumulativeProbabilityFunction;
+import org.apache.commons.rng.sampling.distribution.DiscreteSampler;
+import org.apache.commons.rng.sampling.distribution.GeometricSampler;
+import 
org.apache.commons.rng.sampling.distribution.InverseTransformDiscreteSampler;
+
+/**
+ * Executes a benchmark to compare the speed of generation of Geometric random 
numbers
+ * using different methods.
+ */
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.MICROSECONDS)
+@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
+@State(Scope.Benchmark)
+@Fork(value = 1, jvmArgs = {"-server", "-Xms128M", "-Xmx128M"})
+public class GeometricSamplersPerformance {
+/** Number of samples per run. */
+private static final int NUM_SAMPLES = 1000;
+
+/**
+ * The RandomSource's to use for testing.
+ */
+@State(Scope.Benchmark)
+public static class Sources {
+/**
+ * RNG providers.
+ */
+@Param({"SPLIT_MIX_64",
+"MWC_256",
+"JDK" })
+private String randomSourceName;
+
+/** RNG. */
+private UniformRandomProvider generator;
+
+/**
+ * @return the RNG.
+ */
+public UniformRandomProvider getGenerator() {
+return generator;
+}
+
+/** Instantiates generator. */
+@Setup
+public void setup() {
+final RandomSource randomSource = 
RandomSource.valueOf(randomSourceName);
+generator = RandomSource.create(randomSource);
+}
+}
+
+/**
+ * The probability of success for testing.
+ */
+@State(Scope.Benchmark)
+public static class ProbabilityOfSuccess {
+/**
+ * The probability.
+ */
+@Param({ &q

[commons-rng] 02/02: Fixed MathJax support in the Javadocs.

2019-02-14 Thread aherbert
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 c5b93d55314bbdd8aebe54c418792e1563940945
Author: aherbert 
AuthorDate: Thu Feb 14 15:38:54 2019 +

Fixed MathJax support in the Javadocs.

The parent POM uses maven-javadoc-plugin version 3. This changed the
 tag to .
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 36ac983..8f90214 100644
--- a/pom.xml
+++ b/pom.xml
@@ -232,7 +232,7 @@
 maven-javadoc-plugin
 
   
-  ${doclint.javadoc.qualifier} 
${allowscript.javadoc.qualifier} -header '<script type="text/javascript" 
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/${rng.mathjax.version}/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
+  ${doclint.javadoc.qualifier} 
${allowscript.javadoc.qualifier} -header '<script type="text/javascript" 
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/${rng.mathjax.version}/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
   
 
   



[commons-rng] branch master updated (8e1c529 -> c5b93d5)

2019-02-14 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from 8e1c529  Fixed checkstyle violation
 new bacb5d6  Changed equations to use MathJax notation.
 new c5b93d5  Fixed MathJax support in the Javadocs.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../rng/sampling/distribution/GeometricSampler.java| 14 +++---
 pom.xml|  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)



[commons-rng] 01/02: Changed equations to use MathJax notation.

2019-02-14 Thread aherbert
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 bacb5d654343e548837203ef3b19b75f423ed191
Author: aherbert 
AuthorDate: Thu Feb 14 15:23:31 2019 +

Changed equations to use MathJax notation.
---
 .../rng/sampling/distribution/GeometricSampler.java| 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
index 757367d..92b8df2 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/GeometricSampler.java
@@ -25,17 +25,17 @@ import org.apache.commons.rng.UniformRandomProvider;
  * This distribution samples the number of failures before the first 
success taking values in the
  * set {@code [0, 1, 2, ...]}.
  *
- * The sample is computed using a related an exponential distribution. If 
{@code X} is an
- * exponentially distributed random variable with parameter λ, then {@code Y = 
floor(X)} is a
- * geometrically distributed random variable with parameter p = 1 − 
e−λ, with {@code p}
- * the probability of success.
+ * The sample is computed using a related exponential distribution. If \( X 
\) is an
+ * exponentially distributed random variable with parameter \( \lambda \), then
+ * \( Y = \left \lfloor X \right \rfloor \) is a geometrically distributed 
random variable with
+ * parameter \( p = 1 − e^\lambda \), with \( p \) the probability of success.
  *
  * This sampler outperforms using the {@link 
InverseTransformDiscreteSampler} with an appropriate
  * Geometric inverse cumulative probability function.
  *
- * Usage note: As the probability of success ({@code p}) tends towards zero 
the mean of the
- * distribution ({@code (1-p)/p}) tends towards infinity and due to the use of 
{@code int} for the
- * sample this can result in truncation of the distribution.
+ * Usage note: As the probability of success (\( p \)) tends towards zero 
the mean of the
+ * distribution (\( \frac{1-p}{p} \)) tends towards infinity and due to the 
use of {@code int}
+ * for the sample this can result in truncation of the distribution.
  *
  * @see https://en.wikipedia.org/wiki/Geometric_distribution#Related_distributions";>Geometric



[commons-rng] branch master updated: Removed spurious assert statement from ProvidersCommonParametricTest.

2019-02-14 Thread aherbert
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 cb9d99d  Removed spurious assert statement from 
ProvidersCommonParametricTest.
cb9d99d is described below

commit cb9d99d5b78dce706874bf1bf760309d14684873
Author: aherbert 
AuthorDate: Thu Feb 14 17:00:19 2019 +

Removed spurious assert statement from ProvidersCommonParametricTest.

The assertion that the intSeed is not equal to the original seed will
invoke Integer.equals(Object). I think the intention is to test the type
of the seed is correct, not the value.
---
 .../apache/commons/rng/simple/ProvidersCommonParametricTest.java   | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
index 513ddbf..8b58ec4 100644
--- 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
+++ 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java
@@ -97,11 +97,14 @@ public class ProvidersCommonParametricTest {
 int seedCount = 0;
 for (Object s : seeds) {
 ++seedCount;
-if (!(originalSource.isNativeSeed(s))) {
+if (originalSource.isNativeSeed(s)) {
+Assert.assertNotNull("Identified native seed is null", s);
+Assert.assertEquals("Incorrect identification of native seed 
type",
+s.getClass(), originalSeed.getClass());
+} else {
 ++nonNativeSeedCount;
 }
 
-Assert.assertNotEquals(intSeed, originalSeed);
 RandomSource.create(originalSource, s, originalArgs);
 }
 



[commons-rng] branch master updated: Ensure full test coverage of MultiplyWithCarry256.

2019-02-15 Thread aherbert
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 38c0bc6  Ensure full test coverage of MultiplyWithCarry256.
38c0bc6 is described below

commit 38c0bc6ac77181d6a7f106bdfd99be7a5bf63e35
Author: aherbert 
AuthorDate: Fri Feb 15 10:40:48 2019 +

Ensure full test coverage of MultiplyWithCarry256.

This removes the randomness from test coverage due to using random
seeds. Sometimes the conditional to set the carry using the absolute of
the first seed value was never hit.
---
 .../java/org/apache/commons/rng/core/source32/MultiplyWithCarry256.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/commons-rng-core/src/main/java/org/apache/commons/rng/core/source32/MultiplyWithCarry256.java
 
b/commons-rng-core/src/main/java/org/apache/commons/rng/core/source32/MultiplyWithCarry256.java
index 9de791e..bcd60e9 100644
--- 
a/commons-rng-core/src/main/java/org/apache/commons/rng/core/source32/MultiplyWithCarry256.java
+++ 
b/commons-rng-core/src/main/java/org/apache/commons/rng/core/source32/MultiplyWithCarry256.java
@@ -97,7 +97,7 @@ public class MultiplyWithCarry256 extends IntProvider {
 // First element of the "seed" is the initial "carry".
 final int c = tmp[0];
 // Marsaglia's recommendation: 0 <= carry < A.
-carry = (int) ((c < 0 ? -c : c) % A);
+carry = (int) (Math.abs(c) % A);
 
 // Initial state.
 System.arraycopy(tmp, 1, state, 0, Q_SIZE);



[commons-math] 02/02: Fix Javadoc reference.

2019-02-15 Thread aherbert
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-math.git

commit f3719d89ab6a928e8618bbe6a7da8214d9d6eb07
Author: aherbert 
AuthorDate: Fri Feb 15 11:09:44 2019 +

Fix Javadoc reference.
---
 .../apache/commons/math4/distribution/AbstractRealDistribution.java| 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
 
b/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
index f4b0eac..72edd8b 100644
--- 
a/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
+++ 
b/src/main/java/org/apache/commons/math4/distribution/AbstractRealDistribution.java
@@ -37,7 +37,8 @@ import org.apache.commons.math4.util.FastMath;
  *
  * 
  * This base class provides a default factory method for creating
- * a {@link RealDistribution.Sampler sampler instance} that uses the
+ * a {@link 
org.apache.commons.statistics.distribution.ContinuousDistribution.Sampler
+ * sampler instance} that uses the
  * http://en.wikipedia.org/wiki/Inverse_transform_sampling";>
  * inversion method for generating random samples that follow the
  * distribution.



[commons-math] branch master updated (d7d4e4d -> f3719d8)

2019-02-15 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from d7d4e4d  INFRA-17381: Repository moved to "gitbox".
 new 5acefbd  Fixed MathJax Javadoc support for maven-javadoc-plugin 
version 3.
 new f3719d8  Fix Javadoc reference.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml   | 4 ++--
 .../apache/commons/math4/distribution/AbstractRealDistribution.java   | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)



[commons-math] 01/02: Fixed MathJax Javadoc support for maven-javadoc-plugin version 3.

2019-02-15 Thread aherbert
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-math.git

commit 5acefbd61c604660e65ec84348cb0a1434fa2262
Author: aherbert 
AuthorDate: Fri Feb 15 11:01:49 2019 +

Fixed MathJax Javadoc support for maven-javadoc-plugin version 3.
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 45606ba..fcee946 100644
--- a/pom.xml
+++ b/pom.xml
@@ -645,7 +645,7 @@
 maven-javadoc-plugin
 
   
-  ${doclint.javadoc.qualifier} 
${allowscript.javadoc.qualifier} -header '<script type="text/javascript" 
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/${math.mathjax.version}/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
+  ${doclint.javadoc.qualifier} 
${allowscript.javadoc.qualifier} -header '<script type="text/javascript" 
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/${math.mathjax.version}/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
   
 
   
@@ -797,7 +797,7 @@
 org.apache.maven.plugins
 maven-javadoc-plugin
 
-  ${mathjax.javadoc.qualifier} -header '<script 
type="text/javascript" 
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
+  ${mathjax.javadoc.qualifier} -header '<script 
type="text/javascript" 
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
 
   
 



[commons-statistics] branch master updated: Fixed MathJax Javadoc support for maven-javadoc-plugin version 3.

2019-02-15 Thread aherbert
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-statistics.git


The following commit(s) were added to refs/heads/master by this push:
 new 23a6084  Fixed MathJax Javadoc support for maven-javadoc-plugin 
version 3.
23a6084 is described below

commit 23a60849d2830a2a45db45f7b6acd422410be2f8
Author: aherbert 
AuthorDate: Fri Feb 15 11:10:36 2019 +

Fixed MathJax Javadoc support for maven-javadoc-plugin version 3.
---
 pom.xml | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 674980f..8c13614 100644
--- a/pom.xml
+++ b/pom.xml
@@ -257,6 +257,15 @@
   
 
   
+  
+  
+org.apache.maven.plugins
+maven-javadoc-plugin
+
+  -Xdoclint:all --allow-script-in-comments -header 
'<script type="text/javascript" 
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/${rng.mathjax.version}/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
+  
+
+  
 
 
 
@@ -385,7 +394,7 @@
 org.apache.maven.plugins
 maven-javadoc-plugin
 
-  -Xdoclint:all --allow-script-in-comments -header 
'<script type="text/javascript" 
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
+  -Xdoclint:all --allow-script-in-comments -header 
'<script type="text/javascript" 
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/${rng.mathjax.version}/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
   
 
   



[commons-rng] branch master updated: Add missing property for MathJax in JDK 1.8+ profile.

2019-02-15 Thread aherbert
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 eaf8b3b  Add missing property for MathJax in JDK 1.8+ profile.
eaf8b3b is described below

commit eaf8b3be8794dd74d0050c1d0235189ee8f04f7e
Author: Alex Herbert 
AuthorDate: Fri Feb 15 21:17:08 2019 +

Add missing property for MathJax in JDK 1.8+ profile.
---
 pom.xml | 4 
 1 file changed, 4 insertions(+)

diff --git a/pom.xml b/pom.xml
index 8f90214..0c49dcc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -524,6 +524,10 @@
   
 [1.8,)
   
+  
+
+
--allow-script-in-comments
+  
   
 
   



[commons-rng] branch master updated: Fix MathJax javadoc setting in reports section.

2019-02-15 Thread aherbert
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 56f7770  Fix MathJax javadoc setting in reports section.
56f7770 is described below

commit 56f777095e389af62f11658c5bd5bbe163b835cb
Author: Alex Herbert 
AuthorDate: Fri Feb 15 21:51:36 2019 +

Fix MathJax javadoc setting in reports section.

Added missing doclint.javadoc.qualifier property for JDK 1.8+ profile.
---
 pom.xml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 0c49dcc..5b1164b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -329,7 +329,7 @@
 maven-javadoc-plugin
 
   
-  ${doclint.javadoc.qualifier} 
${allowscript.javadoc.qualifier} -header '<script type="text/javascript" 
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/${rng.mathjax.version}/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
+  ${doclint.javadoc.qualifier} 
${allowscript.javadoc.qualifier} -header '<script type="text/javascript" 
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/${rng.mathjax.version}/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>;'
   
 
   
@@ -525,6 +525,8 @@
 [1.8,)
   
   
+
+-Xdoclint:all
 
 
--allow-script-in-comments
   



[commons-rng] 04/04: The --allow-script-in-comments option is specific to java8.

2019-02-15 Thread aherbert
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 485961aa6321e1b3ac2b7968b16a68e36ff882ba
Author: Alex Herbert 
AuthorDate: Fri Feb 15 23:07:43 2019 +

The --allow-script-in-comments option is specific to java8.
---
 pom.xml | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5b1164b..3dfd486 100644
--- a/pom.xml
+++ b/pom.xml
@@ -518,6 +518,18 @@
 
   
 
+
+
+  jdk8-javadoc
+  
+1.8
+  
+  
+
+
+
--allow-script-in-comments
+  
+
 
 
   jdk8-plugins
@@ -527,8 +539,6 @@
   
 
 -Xdoclint:all
-
-
--allow-script-in-comments
   
   
 



[commons-rng] 03/04: Fix 1.2-SNAPSHOT to 1.3-SNAPSHOT in JPMS runApp.sh

2019-02-15 Thread aherbert
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 201b3fbab85b870a540c5a4e0bef97232ee9fba2
Author: Alex Herbert 
AuthorDate: Fri Feb 15 22:39:31 2019 +

Fix 1.2-SNAPSHOT to 1.3-SNAPSHOT in JPMS runApp.sh
---
 commons-rng-examples/examples-jpms/runApp.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commons-rng-examples/examples-jpms/runApp.sh 
b/commons-rng-examples/examples-jpms/runApp.sh
index c90f6e8..53070fd 100755
--- a/commons-rng-examples/examples-jpms/runApp.sh
+++ b/commons-rng-examples/examples-jpms/runApp.sh
@@ -19,7 +19,7 @@
 # "mvn package" from the top level project directory).
 
 TOPDIR=../..
-RNGVERSION=1.2-SNAPSHOT
+RNGVERSION=1.3-SNAPSHOT
 TARGETDIR=target
 
 # Module path.



[commons-rng] 02/04: Disable checkstyle to allow System.out

2019-02-15 Thread aherbert
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 3298d4db2d7e94e3e64b57da81b7fa8d76a67db2
Author: Alex Herbert 
AuthorDate: Fri Feb 15 22:36:27 2019 +

Disable checkstyle to allow System.out
---
 .../commons/rng/examples/sampling/UniformSamplingVisualCheck.java  | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/UniformSamplingVisualCheck.java
 
b/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/UniformSamplingVisualCheck.java
index e102221..8875934 100644
--- 
a/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/UniformSamplingVisualCheck.java
+++ 
b/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/UniformSamplingVisualCheck.java
@@ -41,6 +41,9 @@ public class UniformSamplingVisualCheck {
 new BoxMullerNormalizedGaussianSampler(rng),
 };
 
+// Allow System.out
+// CHECKSTYLE: stop RegexpCheck
+
 /**
  * Program entry point.
  *



[commons-rng] branch master updated (56f7770 -> 485961a)

2019-02-15 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from 56f7770  Fix MathJax javadoc setting in reports section.
 new bd7db46  Fix checkstyle and javadoc in examples sampling 
ProbabilityDensityApproximation
 new 3298d4d  Disable checkstyle to allow System.out
 new 201b3fb  Fix 1.2-SNAPSHOT to 1.3-SNAPSHOT in JPMS runApp.sh
 new 485961a  The --allow-script-in-comments option is specific to java8.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 commons-rng-examples/examples-jpms/runApp.sh   |  2 +-
 .../examples/sampling/ProbabilityDensityApproximation.java |  7 +--
 .../rng/examples/sampling/UniformSamplingVisualCheck.java  |  3 +++
 pom.xml| 14 --
 4 files changed, 21 insertions(+), 5 deletions(-)



[commons-rng] 01/04: Fix checkstyle and javadoc in examples sampling ProbabilityDensityApproximation

2019-02-15 Thread aherbert
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 bd7db4673ec0ed1f41c2db7274344c8bad061117
Author: Alex Herbert 
AuthorDate: Fri Feb 15 22:12:52 2019 +

Fix checkstyle and javadoc in examples sampling
ProbabilityDensityApproximation

This requires suppression of MultipleStringLiteralsCheck to ignore the
use of "# " and " ".
---
 .../rng/examples/sampling/ProbabilityDensityApproximation.java | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/ProbabilityDensityApproximation.java
 
b/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/ProbabilityDensityApproximation.java
index 3fa5ace..be5fb59 100644
--- 
a/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/ProbabilityDensityApproximation.java
+++ 
b/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/ProbabilityDensityApproximation.java
@@ -59,10 +59,11 @@ public class ProbabilityDensityApproximation {
  * @param min Right abscissa of the first bin: every sample smaller
  * than that value will increment an additional bin (of infinite width)
  * placed before the first "equal-width" bin.
- * @param Left abscissa of the last bin: every sample larger than or
+ * @param max abscissa of the last bin: every sample larger than or
  * equal to that value will increment an additional bin (of infinite
  * width) placed after the last "equal-width" bin.
- * @param output Filename.
+ * @param outputFile Filename.
+ * @throws IOException Signals that an I/O exception has occurred.
  */
 private void createDensity(ContinuousSampler sampler,
double min,
@@ -96,6 +97,7 @@ public class ProbabilityDensityApproximation {
 final double norm = 1 / (binSize * numSamples);
 
 final PrintWriter out = new PrintWriter(outputFile);
+// CHECKSTYLE: stop MultipleStringLiteralsCheck
 out.println("# Sampler: " + sampler);
 out.println("# Number of bins: " + numBins);
 out.println("# Min: " + min + " (fraction of samples below: " + 
(belowMin / (double) numSamples) + ")");
@@ -109,6 +111,7 @@ public class ProbabilityDensityApproximation {
 }
 out.println("# " + (max + binHalfSize) + " " + (aboveMax * norm));
 out.close();
+// CHECKSTYLE: resume MultipleStringLiteralsCheck
 }
 
 /**



[commons-rng] 01/02: Use javadoc parameter --allow-script-in-comments for all JDKs after 1.8

2019-02-18 Thread aherbert
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 d4726f319ddc3bcb703298a67beb8774d1a99315
Author: Alex Herbert 
AuthorDate: Mon Feb 18 13:37:47 2019 +

Use javadoc parameter --allow-script-in-comments for all JDKs after 1.8
---
 pom.xml | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/pom.xml b/pom.xml
index 3dfd486..becd924 100644
--- a/pom.xml
+++ b/pom.xml
@@ -518,18 +518,6 @@
 
   
 
-
-
-  jdk8-javadoc
-  
-1.8
-  
-  
-
-
-
--allow-script-in-comments
-  
-
 
 
   jdk8-plugins
@@ -537,6 +525,8 @@
 [1.8,)
   
   
+
+
--allow-script-in-comments
 
 -Xdoclint:all
   



[commons-rng] 02/02: Disable checkstyle warnings in the DiceGameApplication

2019-02-18 Thread aherbert
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 bb374f3cce821e8c8955c8f3af39107dd80ee527
Author: Alex Herbert 
AuthorDate: Mon Feb 18 13:41:34 2019 +

Disable checkstyle warnings in the DiceGameApplication
---
 .../apache/commons/rng/examples/jpms/app/DiceGameApplication.java   | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/commons-rng-examples/examples-jpms/jpms-app/src/main/java/org/apache/commons/rng/examples/jpms/app/DiceGameApplication.java
 
b/commons-rng-examples/examples-jpms/jpms-app/src/main/java/org/apache/commons/rng/examples/jpms/app/DiceGameApplication.java
index e688140..a52b701 100644
--- 
a/commons-rng-examples/examples-jpms/jpms-app/src/main/java/org/apache/commons/rng/examples/jpms/app/DiceGameApplication.java
+++ 
b/commons-rng-examples/examples-jpms/jpms-app/src/main/java/org/apache/commons/rng/examples/jpms/app/DiceGameApplication.java
@@ -47,6 +47,10 @@ public class DiceGameApplication {
 4.3, 2.1);
 }
 
+// Allow System.out and multiple " ---" strings
+// CHECKSTYLE: stop RegexpCheck
+// CHECKSTYLE: stop MultipleStringLiteralsCheck
+
 /**
  * Application's entry point.
  *
@@ -55,7 +59,7 @@ public class DiceGameApplication {
  *  Number of games
  *  Number of players
  *  Number of rounds per game
- *  RNG {@link RandomSource indentifier}
+ *  RNG {@link RandomSource identifier}
  * 
  */
 public static void main(String[] args) {



[commons-rng] branch master updated (485961a -> bb374f3)

2019-02-18 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from 485961a  The --allow-script-in-comments option is specific to java8.
 new d4726f3  Use javadoc parameter --allow-script-in-comments for all JDKs 
after 1.8
 new bb374f3  Disable checkstyle warnings in the DiceGameApplication

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/rng/examples/jpms/app/DiceGameApplication.java |  6 +-
 pom.xml| 14 ++
 2 files changed, 7 insertions(+), 13 deletions(-)



[commons-rng] branch master updated: Add javadoc for thrown exception to UnitSphereSampler

2019-02-19 Thread aherbert
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 cca5966  Add javadoc for thrown exception to UnitSphereSampler
cca5966 is described below

commit cca5966d2e1e0f009915ea662a725c8aaf37aa13
Author: Alex Herbert 
AuthorDate: Tue Feb 19 18:15:29 2019 +

Add javadoc for thrown exception to UnitSphereSampler
---
 .../src/main/java/org/apache/commons/rng/sampling/UnitSphereSampler.java | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/UnitSphereSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/UnitSphereSampler.java
index cbb3785..3dbdb03 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/UnitSphereSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/UnitSphereSampler.java
@@ -37,6 +37,7 @@ public class UnitSphereSampler {
  * @param dimension Space dimension.
  * @param rng Generator for the individual components of the vectors.
  * A shallow copy will be stored in this instance.
+ * @throws IllegalArgumentException If {@code dimension <= 0}
  */
 public UnitSphereSampler(int dimension,
  UniformRandomProvider rng) {



[commons-rng] branch master updated: Test the SmallMeanPoissonSampler sample is bounded to 1000 * mean

2019-02-22 Thread aherbert
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 6172bb5  Test the SmallMeanPoissonSampler sample is bounded to 1000 * 
mean
6172bb5 is described below

commit 6172bb59deaf1bd44748f6551d61f8754e739cb4
Author: Alex Herbert 
AuthorDate: Fri Feb 22 22:06:46 2019 +

Test the SmallMeanPoissonSampler sample is bounded to 1000 * mean
---
 .../distribution/SmallMeanPoissonSamplerTest.java  | 31 +++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSamplerTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSamplerTest.java
index 0d8d5c7..821645b 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSamplerTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSamplerTest.java
@@ -16,8 +16,9 @@
  */
 package org.apache.commons.rng.sampling.distribution;
 
-import org.apache.commons.rng.RestorableUniformRandomProvider;
+import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.simple.RandomSource;
+import org.junit.Assert;
 import org.junit.Test;
 
 /**
@@ -33,7 +34,7 @@ public class SmallMeanPoissonSamplerTest {
  */
 @Test(expected=IllegalArgumentException.class)
 public void testConstructorThrowsWithMeanLargerThanUpperBound() {
-final RestorableUniformRandomProvider rng =
+final UniformRandomProvider rng =
 RandomSource.create(RandomSource.SPLIT_MIX_64);
 @SuppressWarnings("unused")
 SmallMeanPoissonSampler sampler = new SmallMeanPoissonSampler(rng, 
Integer.MAX_VALUE / 2 + 1);
@@ -44,9 +45,33 @@ public class SmallMeanPoissonSamplerTest {
  */
 @Test(expected=IllegalArgumentException.class)
 public void testConstructorThrowsWithZeroMean() {
-final RestorableUniformRandomProvider rng =
+final UniformRandomProvider rng =
 RandomSource.create(RandomSource.SPLIT_MIX_64);
 @SuppressWarnings("unused")
 SmallMeanPoissonSampler sampler = new SmallMeanPoissonSampler(rng, 0);
 }
+
+/**
+ * Test the sample is bounded to 1000 * mean.
+ */
+@Test
+public void testSampleUpperBounds() {
+// If the nextDouble() is always 1 then the sample will hit the upper 
bounds
+final UniformRandomProvider rng = new UniformRandomProvider() {
+public long nextLong(long n) { return 0; }
+public long nextLong() { return 0; }
+public int nextInt(int n) { return 0; }
+public int nextInt() { return 0; }
+public float nextFloat() { return 0; }
+public double nextDouble() { return 1;}
+public void nextBytes(byte[] bytes, int start, int len) {}
+public void nextBytes(byte[] bytes) {}
+public boolean nextBoolean() { return false; }
+};
+for (double mean : new double[] { 0.5, 1, 1.5, 2.2 }) {
+final SmallMeanPoissonSampler sampler = new 
SmallMeanPoissonSampler(rng, mean);
+final int expected = (int) Math.ceil(1000 * mean);
+Assert.assertEquals(expected, sampler.sample());
+}
+}
 }



[commons-rng] branch master updated: Added version property for exec-maven-plugin in JMH benchmark.

2019-02-23 Thread aherbert
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 85ae97b  Added version property for exec-maven-plugin in JMH benchmark.
85ae97b is described below

commit 85ae97b82ae7a0e92eb74716a7c211ea18aecfcf
Author: Alex Herbert 
AuthorDate: Sat Feb 23 20:20:48 2019 +

Added version property for exec-maven-plugin in JMH benchmark.

Removed control of maven-compiler-plugin from 3.1.0 as commons-parent
uses 3.7.0.
---
 commons-rng-examples/examples-jmh/pom.xml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/commons-rng-examples/examples-jmh/pom.xml 
b/commons-rng-examples/examples-jmh/pom.xml
index a7fd662..e935fa7 100644
--- a/commons-rng-examples/examples-jmh/pom.xml
+++ b/commons-rng-examples/examples-jmh/pom.xml
@@ -67,9 +67,10 @@
 
 ${basedir}/../..
 
-
+
 1.13
 benchmarks
+1.6.0
   
 
   
@@ -86,7 +87,6 @@
   
 org.apache.maven.plugins
 maven-compiler-plugin
-3.1
 
   ${maven.compiler.target}
   ${maven.compiler.target}
@@ -96,6 +96,7 @@
   
 org.codehaus.mojo
 exec-maven-plugin
+${exec-maven-plugin.version}
 
   
 benchmark



[commons-rng] 11/21: Removed javadoc.io link for commons-rng-examples README.md

2019-02-25 Thread aherbert
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 7aa35d9c5a5eb5c09f1da7eff69e1a5a19095a72
Author: Alex Herbert 
AuthorDate: Sat Feb 23 21:24:26 2019 +

Removed javadoc.io link for commons-rng-examples README.md
---
 commons-rng-examples/README.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/commons-rng-examples/README.md b/commons-rng-examples/README.md
index cd23ca2..ede4f66 100644
--- a/commons-rng-examples/README.md
+++ b/commons-rng-examples/README.md
@@ -46,7 +46,6 @@ Apache Commons RNG Examples
 [![Build 
Status](https://travis-ci.org/apache/commons-rng.svg)](https://travis-ci.org/apache/commons-rng)
 [![Coverage 
Status](https://coveralls.io/repos/apache/commons-rng/badge.svg)](https://coveralls.io/r/apache/commons-rng)
 [![Maven 
Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-examples/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-examples/)
-[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-rng-examples/1.2.svg)](https://javadoc.io/doc/org.apache.commons/commons-rng-examples/1.2)
 
 Examples of use of the "Commons RNG" library.
   Codes in this module and its sub-modules are not part of the library.



[commons-rng] 09/21: RNG-72: Add new JMH benchmark ConstructionPerformance

2019-02-25 Thread aherbert
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 b1d924422187e25bcd306183192ab076410f0fe9
Author: Alex Herbert 
AuthorDate: Fri Feb 22 21:30:50 2019 +

RNG-72: Add new JMH benchmark ConstructionPerformance
---
 .../rng/examples/jmh/ConstructionPerformance.java  | 535 +
 1 file changed, 535 insertions(+)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
new file mode 100644
index 000..cd405d4
--- /dev/null
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
@@ -0,0 +1,535 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.rng.examples.jmh;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.core.source32.ISAACRandom;
+import org.apache.commons.rng.core.source32.JDKRandom;
+import org.apache.commons.rng.core.source32.KISSRandom;
+import org.apache.commons.rng.core.source32.MersenneTwister;
+import org.apache.commons.rng.core.source32.MultiplyWithCarry256;
+import org.apache.commons.rng.core.source32.Well1024a;
+import org.apache.commons.rng.core.source32.Well19937a;
+import org.apache.commons.rng.core.source32.Well19937c;
+import org.apache.commons.rng.core.source32.Well44497a;
+import org.apache.commons.rng.core.source32.Well44497b;
+import org.apache.commons.rng.core.source32.Well512a;
+import org.apache.commons.rng.core.source64.MersenneTwister64;
+import org.apache.commons.rng.core.source64.SplitMix64;
+import org.apache.commons.rng.core.source64.TwoCmres;
+import org.apache.commons.rng.core.source64.XorShift1024Star;
+import org.apache.commons.rng.core.util.NumberFactory;
+import org.apache.commons.rng.simple.RandomSource;
+
+/**
+ * Executes a benchmark to compare the speed of construction of random number
+ * providers.
+ */
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.MICROSECONDS)
+@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
+@State(Scope.Benchmark)
+@Fork(value = 1, jvmArgs = { "-server", "-Xms128M", "-Xmx128M" })
+public class ConstructionPerformance {
+
+/** The number of different constructor seeds. */
+private static final int SEEDS = 500;
+/**
+ * The maximum seed array size. This is irrespective of data type just to 
ensure
+ * there is enough data in the random seeds. The value is for WELL_44497_A.
+ */
+private static final int MAX_SEED_SIZE = 1391;
+/** The {@link Long} seeds. */
+private static final Long[] LONG_SEEDS;
+/** The {@link Integer} seeds. */
+private static final Integer[] INTEGER_SEEDS;
+/** The {@code long[]} seeds. */
+private static final long[][] LONG_ARRAY_SEEDS;
+/** The {@code int[]} seeds. */
+private static final int[][] INT_ARRAY_SEEDS;
+/** The {@code byte[]} seeds. */
+private static final byte[][] BYTE_ARRAY_SEEDS;
+
+static {
+LONG_SEEDS = new Long[SEEDS];
+INTEGER_SEEDS = new Integer[SEEDS];
+LONG_ARRAY_SEEDS = new long[SEEDS][];
+INT_ARRAY_SEEDS = new int[SEEDS][];
+BYTE_ARRAY_SEEDS = new byte[SEEDS][];
+fina

[commons-rng] 01/21: Updated the README.md using the commons build plugin.

2019-02-25 Thread aherbert
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 f7d09efa808ada68762e7a81581d38fcc64182df
Author: Alex Herbert 
AuthorDate: Sat Feb 16 11:30:36 2019 +

Updated the README.md using the commons build plugin.
---
 README.md  | 33 +++---
 commons-rng-client-api/README.md   |  8 +++---
 commons-rng-core/README.md | 12 +---
 commons-rng-examples/README.md | 14 +
 commons-rng-examples/examples-jmh/README.md| 16 +--
 commons-rng-examples/examples-jpms/README.md   | 16 +--
 .../examples-jpms/jpms-app/README.md   |  8 +++---
 .../examples-jpms/jpms-lib/README.md   |  8 +++---
 commons-rng-examples/examples-quadrature/README.md | 16 +--
 commons-rng-examples/examples-sampling/README.md   | 16 +--
 commons-rng-examples/examples-stress/README.md | 16 +--
 commons-rng-sampling/README.md |  8 +++---
 commons-rng-simple/README.md   |  8 +++---
 13 files changed, 93 insertions(+), 86 deletions(-)

diff --git a/README.md b/README.md
index 485739d..71ec933 100644
--- a/README.md
+++ b/README.md
@@ -34,8 +34,8 @@
  | 3) Example Properties|
  |  |
  |  |
- |rng|
- |1.0|
+ |math   |
+ |1.2|
  | |
  |  |
  +==+
@@ -43,19 +43,18 @@
 Apache Commons RNG
 ===
 
-[![Build 
Status](https://travis-ci.org/apache/commons-rng.svg?branch=master)](https://travis-ci.org/apache/commons-rng)
-[![Coverage 
Status](https://coveralls.io/repos/github/apache/commons-rng/badge.svg?branch=master)](https://coveralls.io/github/apache/commons-rng?branch=master)
-[![Maven 
Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-simple/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-simple/)
-[![Maven 
Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-sampling/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-sampling/)
-[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
+[![Build 
Status](https://travis-ci.org/apache/commons-rng.svg)](https://travis-ci.org/apache/commons-rng)
+[![Coverage 
Status](https://coveralls.io/repos/apache/commons-rng/badge.svg)](https://coveralls.io/r/apache/commons-rng)
+[![Maven 
Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-parent/)
+[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-rng-parent/1.2.svg)](https://javadoc.io/doc/org.apache.commons/commons-rng-parent/1.2)
 
-The Apache Commons RNG project provides Java implementations of pseudo-random 
numbers generators.
+The Apache Commons RNG project provides pure-Java implementation of 
pseudo-random generators.
 
 Documentation
 -
 
-More information can be found on the 
[homepage](https://commons.apache.org/proper/commons-rng).
-The [Javadoc](https://commons.apache.org/proper/commons-rng/apidocs) can be 
browsed.
+More information can be found on the [Apache Commons RNG 
homepage](https://commons.apache.org/proper/commons-rng).
+The 
[Javadoc](https://commons.apache.org/proper/commons-rng/javadocs/api-release) 
can be browsed.
 Questions related to the usage of Apache Commons RNG should be posted to the 
[user mailing list][ml].
 
 Where can I get the latest release?
@@ -67,15 +66,15 @@ Alternatively you can pull it from the central Maven 
repositories:
 ```xml
 
   org.apache.commons
-  commons-rng
-  1.1
+  commons-rng-parent
+  1.2
 
 ```
 
 Contributing
 
 
-We accept PRs via github. The [developer mailing list][ml] is the main channel 
of communication for contributors.
+We accept Pull Requests via GitHub. The [developer mailing list][ml] is the 
main channel of communication for contributors.
 There are some guidelines which will make applying PRs easier for us:
 + No tabs! Please use spaces for indentation.
 + Respect the code style.
@@ -87,7 +86,9 @@ You can learn more about contributing via GitHub in our 
[contribution guidelines
 
 License
 ---
-Code is under the [Apache Licence 
v2](https://www.apache.org/licenses/LICENSE-2.0.txt

[commons-rng] branch master updated (85ae97b -> dc0786b)

2019-02-25 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from 85ae97b  Added version property for exec-maven-plugin in JMH benchmark.
 new a71ba4a  Document use of null RandomGenerator in the distribution 
samplers tests.
 new f7d09ef  Updated the README.md using the commons build plugin.
 new b82bd31  Updated main README.md to fix javadoc links to the core 
modules.
 new af26a0e  Fix commons homepage title. Fix type in donate link.
 new 19c837c  Change homepage to Homepage
 new 7786514  Fix javadoc browse link for sub-modules
 new d5af347  Add client API browse link
 new 8adf439  Added maven XML for sampling
 new 7aa35d9  Removed javadoc.io link for commons-rng-examples README.md
 new 1311c7b  Merge branch 'update-readme' of 
https://github.com/aherbert/commons-rng into updatereadme
 new 56bdb01  Update description in quadrature pom to refer to integration.
 new 5d4e8a5  Merge branch 'updatereadme'
 new 634ec03  RNG-71: Validate parameters for the distribution samplers
 new 53a87e9  Merge branch 'improvement-RNG-71' of 
https://github.com/aherbert/commons-rng into aherbert-improvement-RNG-71
     new 4d42b1b  Merge branch 'aherbert-improvement-RNG-71'
 new 6746242  Track changes.
 new b1d9244  RNG-72: Add new JMH benchmark ConstructionPerformance
 new 4917cf0  RNG-72: Added benchmark using reflection to 
ConstructionPerformance
 new 83f0e29  Merge branch 'feature-RNG-72' of 
https://github.com/aherbert/commons-rng into aherbert-feature-RNG-72
 new 9ac34c7  Track changes.
 new dc0786b  Merge branch 'aherbert-feature-RNG-72'

The 21 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 README.md  |  41 +-
 commons-rng-client-api/README.md   |  16 +-
 commons-rng-core/README.md |  20 +-
 commons-rng-examples/README.md |  21 +-
 commons-rng-examples/examples-jmh/README.md|  20 +-
 .../rng/examples/jmh/ConstructionPerformance.java  | 632 +
 commons-rng-examples/examples-jpms/README.md   |  20 +-
 .../examples-jpms/jpms-app/README.md   |  16 +-
 .../examples-jpms/jpms-lib/README.md   |  16 +-
 commons-rng-examples/examples-quadrature/README.md |  22 +-
 commons-rng-examples/examples-quadrature/pom.xml   |   2 +-
 commons-rng-examples/examples-sampling/README.md   |  20 +-
 commons-rng-examples/examples-stress/README.md |  20 +-
 commons-rng-sampling/README.md |  16 +-
 .../AhrensDieterExponentialSampler.java|   4 +
 .../AhrensDieterMarsagliaTsangGammaSampler.java|  10 +
 .../distribution/BoxMullerGaussianSampler.java |   5 +
 .../distribution/BoxMullerLogNormalSampler.java|   1 +
 .../sampling/distribution/ChengBetaSampler.java|   7 +
 .../rng/sampling/distribution/GaussianSampler.java |   5 +
 .../InverseTransformParetoSampler.java |   7 +
 .../distribution/LargeMeanPoissonSampler.java  |   4 +-
 .../sampling/distribution/LogNormalSampler.java|   7 +
 .../distribution/SmallMeanPoissonSampler.java  |   7 +-
 .../AhrensDieterExponentialSamplerTest.java}   |  24 +-
 ...AhrensDieterMarsagliaTsangGammaSamplerTest.java |  54 ++
 .../BoxMullerGaussianSamplerTest.java} |  25 +-
 .../BoxMullerLogNormalSamplerTest.java |  54 ++
 .../distribution/ChengBetaSamplerTest.java |  54 ++
 .../distribution/ContinuousSamplersList.java   |  78 +--
 .../distribution/ContinuousUniformSamplerTest.java |  51 ++
 .../distribution/DiscreteSamplersList.java |  44 +-
 .../distribution/DiscreteUniformSamplerTest.java}  |  25 +-
 .../distribution/GaussianSamplerTest.java} |  26 +-
 .../distribution/GeometricSamplerTest.java |  17 +-
 .../InverseTransformParetoSamplerTest.java |  54 ++
 .../distribution/LargeMeanPoissonSamplerTest.java  |  10 +-
 .../distribution/LogNormalSamplerTest.java |  56 ++
 .../RejectionInversionZipfSamplerTest.java |  54 ++
 .../distribution/SmallMeanPoissonSamplerTest.java  |  12 +-
 commons-rng-simple/README.md   |  16 +-
 src/changes/changes.xml|   8 +-
 42 files changed, 1361 insertions(+), 240 deletions(-)
 create mode 100644 
commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
 copy 
commons-rng-sampling/src/{main/java/org/apache/commons/rng/sampling/distribution/ContinuousSampler.java
 => 
test/java/org/apa

[commons-rng] 06/21: Add client API browse link

2019-02-25 Thread aherbert
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 d5af347e763178b08d9738fff5a28e1154b1035a
Author: Alex Herbert 
AuthorDate: Sun Feb 17 14:44:39 2019 +

Add client API browse link
---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
index 5e853e6..8723e8e 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,7 @@ Documentation
 
 More information can be found on the [Apache Commons RNG 
homepage](https://commons.apache.org/proper/commons-rng). The Javadoc for each 
of the modules can be browsed:
 
+- [Commons RNG Client 
API](https://commons.apache.org/proper/commons-rng/commons-rng-client-api/apidocs/)
 - [Commons RNG 
Core](https://commons.apache.org/proper/commons-rng/commons-rng-core/apidocs/)
 - [Commons RNG 
Simple](https://commons.apache.org/proper/commons-rng/commons-rng-simple/apidocs/)
 - [Commons RNG 
Sampling](https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/)



[commons-rng] 02/21: Updated main README.md to fix javadoc links to the core modules.

2019-02-25 Thread aherbert
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 b82bd31ba8f0b62e1d90b84818105f13f82c8d3f
Author: Alex Herbert 
AuthorDate: Sun Feb 17 13:53:59 2019 +

Updated main README.md to fix javadoc links to the core modules.

Updated all the donation titles to use 'Commons RNG'.
---
 README.md  | 22 +-
 commons-rng-client-api/README.md   |  8 
 commons-rng-core/README.md |  8 
 commons-rng-examples/README.md |  8 
 commons-rng-examples/examples-jmh/README.md|  8 
 commons-rng-examples/examples-jpms/README.md   |  8 
 .../examples-jpms/jpms-app/README.md   |  8 
 .../examples-jpms/jpms-lib/README.md   |  8 
 commons-rng-examples/examples-quadrature/README.md |  8 
 commons-rng-examples/examples-sampling/README.md   |  8 
 commons-rng-examples/examples-stress/README.md |  8 
 commons-rng-sampling/README.md |  8 
 commons-rng-simple/README.md   |  8 
 13 files changed, 61 insertions(+), 57 deletions(-)

diff --git a/README.md b/README.md
index 71ec933..47af962 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@
  | 3) Example Properties|
  |  |
  |  |
- |math   |
+ |rng|
  |1.2|
  | |
  |  |
@@ -45,28 +45,32 @@ Apache Commons RNG
 
 [![Build 
Status](https://travis-ci.org/apache/commons-rng.svg)](https://travis-ci.org/apache/commons-rng)
 [![Coverage 
Status](https://coveralls.io/repos/apache/commons-rng/badge.svg)](https://coveralls.io/r/apache/commons-rng)
-[![Maven 
Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-parent/)
-[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-rng-parent/1.2.svg)](https://javadoc.io/doc/org.apache.commons/commons-rng-parent/1.2)
+[![Maven 
Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-simple/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-simple/)
+[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-rng-simple/1.2.svg)](https://javadoc.io/doc/org.apache.commons/commons-rng-simple/1.2)
 
 The Apache Commons RNG project provides pure-Java implementation of 
pseudo-random generators.
 
 Documentation
 -
 
-More information can be found on the [Apache Commons RNG 
homepage](https://commons.apache.org/proper/commons-rng).
-The 
[Javadoc](https://commons.apache.org/proper/commons-rng/javadocs/api-release) 
can be browsed.
+More information can be found on the [Apache Commons RNG 
homepage](https://commons.apache.org/proper/commons-rng). The Javadoc for each 
of the modules can be browsed:
+
+- [Commons RNG 
Core](https://commons.apache.org/proper/commons-rng/commons-rng-core/apidocs/)
+- [Commons RNG 
Simple](https://commons.apache.org/proper/commons-rng/commons-rng-simple/apidocs/)
+- [Commons RNG 
Sampling](https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/)
+
 Questions related to the usage of Apache Commons RNG should be posted to the 
[user mailing list][ml].
 
 Where can I get the latest release?
 ---
 You can download source and binaries from our [download 
page](https://commons.apache.org/proper/commons-rng/download_rng.cgi).
 
-Alternatively you can pull it from the central Maven repositories:
+Alternatively you can pull it from the central Maven repositories, e.g.:
 
 ```xml
 
   org.apache.commons
-  commons-rng-parent
+  commons-rng-simple
   1.2
 
 ```
@@ -92,12 +96,12 @@ See the `NOTICE.txt` file for required notices and 
attributions.
 
 Donations
 -
-You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.org/foundation/contributing.html) to support the 
development.
+You like Apache Commons RNG? The [donate back to the 
ASF](https://www.apache.org/foundation/contributing.html) to support the 
development.
 
 Additional Resources
 
 
-+ [Apache Commons Homepage](https://commons.apache.org/)
++ [Apache Commons RNG homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
 

[commons-rng] 07/21: Added maven XML for sampling

2019-02-25 Thread aherbert
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 8adf439f6b81dc2f63243acfb5f96b528bf93ffb
Author: Alex Herbert 
AuthorDate: Sun Feb 17 14:51:07 2019 +

Added maven XML for sampling
---
 README.md | 5 +
 1 file changed, 5 insertions(+)

diff --git a/README.md b/README.md
index 8723e8e..a80d6d9 100644
--- a/README.md
+++ b/README.md
@@ -74,6 +74,11 @@ Alternatively you can pull it from the central Maven 
repositories, e.g.:
   commons-rng-simple
   1.2
 
+
+  org.apache.commons
+  commons-rng-sampling
+  1.2
+
 ```
 
 Contributing



[commons-rng] 05/21: Fix javadoc browse link for sub-modules

2019-02-25 Thread aherbert
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 778651408b1c4dde38f619d6e15b331599213a1b
Author: Alex Herbert 
AuthorDate: Sun Feb 17 14:42:00 2019 +

Fix javadoc browse link for sub-modules
---
 commons-rng-client-api/README.md  | 2 +-
 commons-rng-core/README.md| 2 +-
 commons-rng-examples/README.md| 2 +-
 commons-rng-examples/examples-jmh/README.md   | 2 +-
 commons-rng-examples/examples-jpms/README.md  | 2 +-
 commons-rng-examples/examples-jpms/jpms-app/README.md | 2 +-
 commons-rng-examples/examples-jpms/jpms-lib/README.md | 2 +-
 commons-rng-examples/examples-quadrature/README.md| 2 +-
 commons-rng-examples/examples-sampling/README.md  | 2 +-
 commons-rng-examples/examples-stress/README.md| 2 +-
 commons-rng-sampling/README.md| 2 +-
 commons-rng-simple/README.md  | 2 +-
 12 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/commons-rng-client-api/README.md b/commons-rng-client-api/README.md
index 128c966..2ac21b9 100644
--- a/commons-rng-client-api/README.md
+++ b/commons-rng-client-api/README.md
@@ -54,7 +54,7 @@ Documentation
 -
 
 More information can be found on the [Apache Commons RNG 
homepage](https://commons.apache.org/proper/commons-rng).
-The 
[Javadoc](https://commons.apache.org/proper/commons-rng/javadocs/api-release) 
can be browsed.
+The 
[Javadoc](https://commons.apache.org/proper/commons-rng/commons-rng-client-api/apidocs/)
 can be browsed.
 Questions related to the usage of Apache Commons RNG Client API should be 
posted to the [user mailing list][ml].
 
 Where can I get the latest release?
diff --git a/commons-rng-core/README.md b/commons-rng-core/README.md
index fd1ee34..2652d4c 100644
--- a/commons-rng-core/README.md
+++ b/commons-rng-core/README.md
@@ -58,7 +58,7 @@ Documentation
 -
 
 More information can be found on the [Apache Commons RNG 
homepage](https://commons.apache.org/proper/commons-rng).
-The 
[Javadoc](https://commons.apache.org/proper/commons-rng/javadocs/api-release) 
can be browsed.
+The 
[Javadoc](https://commons.apache.org/proper/commons-rng/commons-rng-core/apidocs/)
 can be browsed.
 Questions related to the usage of Apache Commons RNG Core should be posted to 
the [user mailing list][ml].
 
 Where can I get the latest release?
diff --git a/commons-rng-examples/README.md b/commons-rng-examples/README.md
index 0c078ab..cd23ca2 100644
--- a/commons-rng-examples/README.md
+++ b/commons-rng-examples/README.md
@@ -57,7 +57,7 @@ Documentation
 -
 
 More information can be found on the [Apache Commons RNG 
homepage](https://commons.apache.org/proper/commons-rng).
-The 
[Javadoc](https://commons.apache.org/proper/commons-rng/javadocs/api-release) 
can be browsed.
+The 
[Javadoc](https://commons.apache.org/proper/commons-rng/commons-rng-examples/apidocs/)
 can be browsed.
 Questions related to the usage of Apache Commons RNG Examples should be posted 
to the [user mailing list][ml].
 
 Where can I get the latest release?
diff --git a/commons-rng-examples/examples-jmh/README.md 
b/commons-rng-examples/examples-jmh/README.md
index 461faee..6b1ac19 100644
--- a/commons-rng-examples/examples-jmh/README.md
+++ b/commons-rng-examples/examples-jmh/README.md
@@ -55,7 +55,7 @@ Documentation
 -
 
 More information can be found on the [Apache Commons RNG 
homepage](https://commons.apache.org/proper/commons-rng).
-The 
[Javadoc](https://commons.apache.org/proper/commons-rng/javadocs/api-release) 
can be browsed.
+The 
[Javadoc](https://commons.apache.org/proper/commons-rng/commons-rng-examples-jmh/apidocs/)
 can be browsed.
 Questions related to the usage of JMH Benchmark should be posted to the [user 
mailing list][ml].
 
 Where can I get the latest release?
diff --git a/commons-rng-examples/examples-jpms/README.md 
b/commons-rng-examples/examples-jpms/README.md
index 072a619..49e122f 100644
--- a/commons-rng-examples/examples-jpms/README.md
+++ b/commons-rng-examples/examples-jpms/README.md
@@ -54,7 +54,7 @@ Documentation
 -
 
 More information can be found on the [Apache Commons RNG 
homepage](https://commons.apache.org/proper/commons-rng).
-The 
[Javadoc](https://commons.apache.org/proper/commons-rng/javadocs/api-release) 
can be browsed.
+The 
[Javadoc](https://commons.apache.org/proper/commons-rng/commons-rng-examples-jpms/apidocs/)
 can be browsed.
 Questions related to the usage of JPMS Integration test should be posted to 
the [user mailing list][ml].
 
 Where can I get the latest release?
diff --git a/commons-rng-examples/examples-jpms/jpms-app/README.md 
b/commons-rng-examples/examples-jpms/jpms-app/README.md
index c94e070..232f236 100644
--- a/commons-rng-examples/examples-jpms/jpms-app/README.md
+++ b

[commons-rng] 04/21: Change homepage to Homepage

2019-02-25 Thread aherbert
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 19c837cb832d46ef649c2459a9675d5ad86d4af5
Author: Alex Herbert 
AuthorDate: Sun Feb 17 14:09:55 2019 +

Change homepage to Homepage
---
 README.md | 2 +-
 commons-rng-client-api/README.md  | 2 +-
 commons-rng-core/README.md| 2 +-
 commons-rng-examples/README.md| 2 +-
 commons-rng-examples/examples-jmh/README.md   | 2 +-
 commons-rng-examples/examples-jpms/README.md  | 2 +-
 commons-rng-examples/examples-jpms/jpms-app/README.md | 2 +-
 commons-rng-examples/examples-jpms/jpms-lib/README.md | 2 +-
 commons-rng-examples/examples-quadrature/README.md| 2 +-
 commons-rng-examples/examples-sampling/README.md  | 2 +-
 commons-rng-examples/examples-stress/README.md| 2 +-
 commons-rng-sampling/README.md| 2 +-
 commons-rng-simple/README.md  | 2 +-
 13 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index aa4d05a..5e853e6 100644
--- a/README.md
+++ b/README.md
@@ -101,7 +101,7 @@ You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.or
 Additional Resources
 
 
-+ [Apache Commons homepage](https://commons.apache.org/)
++ [Apache Commons Homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
 + `#apache-commons` IRC channel on `irc.freenode.org`
diff --git a/commons-rng-client-api/README.md b/commons-rng-client-api/README.md
index 582e59f..128c966 100644
--- a/commons-rng-client-api/README.md
+++ b/commons-rng-client-api/README.md
@@ -97,7 +97,7 @@ You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.or
 Additional Resources
 
 
-+ [Apache Commons homepage](https://commons.apache.org/)
++ [Apache Commons Homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
 + `#apache-commons` IRC channel on `irc.freenode.org`
diff --git a/commons-rng-core/README.md b/commons-rng-core/README.md
index e865cdc..fd1ee34 100644
--- a/commons-rng-core/README.md
+++ b/commons-rng-core/README.md
@@ -101,7 +101,7 @@ You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.or
 Additional Resources
 
 
-+ [Apache Commons homepage](https://commons.apache.org/)
++ [Apache Commons Homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
 + `#apache-commons` IRC channel on `irc.freenode.org`
diff --git a/commons-rng-examples/README.md b/commons-rng-examples/README.md
index f5206d8..0c078ab 100644
--- a/commons-rng-examples/README.md
+++ b/commons-rng-examples/README.md
@@ -100,7 +100,7 @@ You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.or
 Additional Resources
 
 
-+ [Apache Commons homepage](https://commons.apache.org/)
++ [Apache Commons Homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
 + `#apache-commons` IRC channel on `irc.freenode.org`
diff --git a/commons-rng-examples/examples-jmh/README.md 
b/commons-rng-examples/examples-jmh/README.md
index a4fd5c9..461faee 100644
--- a/commons-rng-examples/examples-jmh/README.md
+++ b/commons-rng-examples/examples-jmh/README.md
@@ -98,7 +98,7 @@ You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.or
 Additional Resources
 
 
-+ [Apache Commons homepage](https://commons.apache.org/)
++ [Apache Commons Homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
 + `#apache-commons` IRC channel on `irc.freenode.org`
diff --git a/commons-rng-examples/examples-jpms/README.md 
b/commons-rng-examples/examples-jpms/README.md
index 16fea57..072a619 100644
--- a/commons-rng-examples/examples-jpms/README.md
+++ b/commons-rng-examples/examples-jpms/README.md
@@ -97,7 +97,7 @@ You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.or
 Additional Resources
 
 
-+ [Apache Commons homepage](https://commons.apache.org/)
++ [Apache Commons Homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https

[commons-rng] 10/21: RNG-72: Added benchmark using reflection to ConstructionPerformance

2019-02-25 Thread aherbert
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 4917cf049c1f10449a7e912167716d3e206fc009
Author: Alex Herbert 
AuthorDate: Sat Feb 23 20:13:53 2019 +

RNG-72: Added benchmark using reflection to ConstructionPerformance
---
 .../rng/examples/jmh/ConstructionPerformance.java  | 105 -
 1 file changed, 101 insertions(+), 4 deletions(-)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
index cd405d4..4c201f3 100644
--- 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
@@ -31,6 +31,7 @@ import org.openjdk.jmh.annotations.State;
 import org.openjdk.jmh.annotations.Warmup;
 import org.openjdk.jmh.infra.Blackhole;
 
+import java.lang.reflect.Constructor;
 import java.util.Arrays;
 import java.util.concurrent.TimeUnit;
 
@@ -52,6 +53,7 @@ import org.apache.commons.rng.core.source64.TwoCmres;
 import org.apache.commons.rng.core.source64.XorShift1024Star;
 import org.apache.commons.rng.core.util.NumberFactory;
 import org.apache.commons.rng.simple.RandomSource;
+import 
org.apache.commons.rng.simple.internal.ProviderBuilder.RandomSourceInternal;
 
 /**
  * Executes a benchmark to compare the speed of construction of random number
@@ -143,6 +145,12 @@ public class ConstructionPerformance {
 /** The {@code byte[]} seeds, truncated to the appropriate length for 
the native seed type. */
 private byte[][] byteSeeds;
 
+/** The implementing class for the random source. */
+private Class implementingClass;
+
+/** The constructor. */
+private Constructor constructor;
+
 /**
  * Gets the random source.
  *
@@ -179,9 +187,32 @@ public class ConstructionPerformance {
 return byteSeeds;
 }
 
-/** Create the random source and the test seeds. */
+/**
+ * Gets the implementing class.
+ *
+ * @return the implementing class
+ */
+public Class getImplementingClass() {
+return implementingClass;
+}
+
+/**
+ * Gets the constructor.
+ *
+ * @return the constructor
+ */
+public Constructor getConstructor() {
+return constructor;
+}
+
+/**
+ * Create the random source and the test seeds.
+ *
+ * @throws NoSuchMethodException If the constructor cannot be found
+ */
+@SuppressWarnings("unchecked")
 @Setup(value=Level.Trial)
-public void setup() {
+public void setup() throws NoSuchMethodException {
 randomSource = RandomSource.valueOf(randomSourceName);
 nativeSeeds = findNativeSeeds(randomSource);
 
@@ -203,6 +234,10 @@ public class ConstructionPerformance {
 for (int i = 0; i < SEEDS; i++) {
 byteSeeds[i] = Arrays.copyOf(BYTE_ARRAY_SEEDS[i], byteSize);
 }
+
+// Cache the class type and constructor
+implementingClass = getRandomSourceInternal(randomSource).getRng();
+constructor = (Constructor) 
implementingClass.getConstructor(nativeSeeds[0].getClass());
 }
 
 /**
@@ -230,6 +265,9 @@ public class ConstructionPerformance {
  */
 private static Object[] findNativeSeeds(RandomSource randomSource) {
 switch (randomSource) {
+case TWO_CMRES:
+case TWO_CMRES_SELECT:
+return INTEGER_SEEDS;
 case JDK:
 case SPLIT_MIX_64:
 return LONG_SEEDS;
@@ -241,8 +279,6 @@ public class ConstructionPerformance {
 case WELL_44497_B:
 case MT:
 case ISAAC:
-case TWO_CMRES:
-case TWO_CMRES_SELECT:
 case MWC_256:
 case KISS:
 return INT_ARRAY_SEEDS;
@@ -324,6 +360,35 @@ public class ConstructionPerformance {
 throw new AssertionError("Unknown native seed element byte 
size");
 }
 }
+
+/**
+ * Gets the random source internal.
+ *
+ * @param randomSource the random source
+ * @return the random source internal
+ */
+private static RandomSourceInternal 
getRandomSourceInternal(RandomSource randomSource) {
+switch (randomSource) {
+case JDK: return RandomSourceInternal.JDK;
+case WELL_512_A: return RandomSourceInternal.WELL_512_A;
+c

[commons-rng] 19/21: Merge branch 'feature-RNG-72' of https://github.com/aherbert/commons-rng into aherbert-feature-RNG-72

2019-02-25 Thread aherbert
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 83f0e297b6e772611fd9b4da652a1e5904586e15
Merge: 6746242 4917cf0
Author: aherbert 
AuthorDate: Mon Feb 25 13:19:12 2019 +

Merge branch 'feature-RNG-72' of https://github.com/aherbert/commons-rng 
into aherbert-feature-RNG-72

 .../rng/examples/jmh/ConstructionPerformance.java  | 632 +
 1 file changed, 632 insertions(+)



[commons-rng] 16/21: Merge branch 'improvement-RNG-71' of https://github.com/aherbert/commons-rng into aherbert-improvement-RNG-71

2019-02-25 Thread aherbert
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 53a87e9573f1d3bda6e7e74fb990ec7752f6b6eb
Merge: 5d4e8a5 634ec03
Author: aherbert 
AuthorDate: Mon Feb 25 13:16:26 2019 +

Merge branch 'improvement-RNG-71' of 
https://github.com/aherbert/commons-rng into aherbert-improvement-RNG-71

 .../AhrensDieterExponentialSampler.java|  4 ++
 .../AhrensDieterMarsagliaTsangGammaSampler.java| 10 
 .../distribution/BoxMullerGaussianSampler.java |  5 ++
 .../distribution/BoxMullerLogNormalSampler.java|  1 +
 .../sampling/distribution/ChengBetaSampler.java|  7 +++
 .../rng/sampling/distribution/GaussianSampler.java |  5 ++
 .../InverseTransformParetoSampler.java |  7 +++
 .../distribution/LargeMeanPoissonSampler.java  |  4 +-
 .../sampling/distribution/LogNormalSampler.java|  7 +++
 .../distribution/SmallMeanPoissonSampler.java  |  7 +--
 .../AhrensDieterExponentialSamplerTest.java| 39 +++
 ...AhrensDieterMarsagliaTsangGammaSamplerTest.java | 54 +
 .../distribution/BoxMullerGaussianSamplerTest.java | 40 
 .../BoxMullerLogNormalSamplerTest.java | 54 +
 .../distribution/ChengBetaSamplerTest.java | 54 +
 .../distribution/ContinuousUniformSamplerTest.java | 51 
 .../distribution/DiscreteUniformSamplerTest.java   | 38 +++
 .../sampling/distribution/GaussianSamplerTest.java | 41 
 .../distribution/GeometricSamplerTest.java | 17 +++
 .../InverseTransformParetoSamplerTest.java | 54 +
 .../distribution/LargeMeanPoissonSamplerTest.java  | 10 ++--
 .../distribution/LogNormalSamplerTest.java | 56 ++
 .../RejectionInversionZipfSamplerTest.java | 54 +
 .../distribution/SmallMeanPoissonSamplerTest.java  | 12 ++---
 24 files changed, 607 insertions(+), 24 deletions(-)

diff --cc 
commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSamplerTest.java
index 821645b,93ea94d..92a60fb
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSamplerTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSamplerTest.java
@@@ -34,10 -29,11 +30,11 @@@ public class SmallMeanPoissonSamplerTes
   */
  @Test(expected=IllegalArgumentException.class)
  public void testConstructorThrowsWithMeanLargerThanUpperBound() {
 -final RestorableUniformRandomProvider rng =
 +final UniformRandomProvider rng =
  RandomSource.create(RandomSource.SPLIT_MIX_64);
+ final double mean = Integer.MAX_VALUE / 2 + 1;
  @SuppressWarnings("unused")
- SmallMeanPoissonSampler sampler = new SmallMeanPoissonSampler(rng, 
Integer.MAX_VALUE / 2 + 1);
+ SmallMeanPoissonSampler sampler = new SmallMeanPoissonSampler(rng, 
mean);
  }
  
  /**
@@@ -45,33 -41,10 +42,34 @@@
   */
  @Test(expected=IllegalArgumentException.class)
  public void testConstructorThrowsWithZeroMean() {
 -final RestorableUniformRandomProvider rng =
 +final UniformRandomProvider rng =
  RandomSource.create(RandomSource.SPLIT_MIX_64);
+ final double mean = 0;
  @SuppressWarnings("unused")
- SmallMeanPoissonSampler sampler = new SmallMeanPoissonSampler(rng, 0);
+ SmallMeanPoissonSampler sampler = new SmallMeanPoissonSampler(rng, 
mean);
  }
 +
 +/**
 + * Test the sample is bounded to 1000 * mean.
 + */
 +@Test
 +public void testSampleUpperBounds() {
 +// If the nextDouble() is always 1 then the sample will hit the upper 
bounds
 +final UniformRandomProvider rng = new UniformRandomProvider() {
 +public long nextLong(long n) { return 0; }
 +public long nextLong() { return 0; }
 +public int nextInt(int n) { return 0; }
 +public int nextInt() { return 0; }
 +public float nextFloat() { return 0; }
 +public double nextDouble() { return 1;}
 +public void nextBytes(byte[] bytes, int start, int len) {}
 +public void nextBytes(byte[] bytes) {}
 +public boolean nextBoolean() { return false; }
 +};
 +for (double mean : new double[] { 0.5, 1, 1.5, 2.2 }) {
 +final SmallMeanPoissonSampler sampler = new 
SmallMeanPoissonSampler(rng, mean);
 +final int expected = (int) Math.ceil(1000 * mean);
 +Assert.assertEquals(expected, sampler.sample());
 +}
 +}
  }



[commons-rng] 21/21: Merge branch 'aherbert-feature-RNG-72'

2019-02-25 Thread aherbert
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 dc0786b2604ff2a2d6ac37a0621baecd2af29ea5
Merge: 6746242 9ac34c7
Author: aherbert 
AuthorDate: Mon Feb 25 13:20:51 2019 +

Merge branch 'aherbert-feature-RNG-72'

Closes #22

 .../rng/examples/jmh/ConstructionPerformance.java  | 632 +
 src/changes/changes.xml|   5 +-
 2 files changed, 636 insertions(+), 1 deletion(-)



[commons-rng] 08/21: RNG-71: Validate parameters for the distribution samplers

2019-02-25 Thread aherbert
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 634ec038748f7b2fa064d8586200bbad4cdda58c
Author: Alex Herbert 
AuthorDate: Sun Feb 17 22:05:56 2019 +

RNG-71: Validate parameters for the distribution samplers

This adds checks matching those found in the commons-math3 distributions
to the samplers. The existing validation checks in the PoissonSampler
have had their exception messages changed for consistency. A test for
the ContinuousUniformSampler was added to demonstrate no range checks
are required.
---
 .../AhrensDieterExponentialSampler.java|  4 ++
 .../AhrensDieterMarsagliaTsangGammaSampler.java| 10 +
 .../distribution/BoxMullerGaussianSampler.java |  5 +++
 .../distribution/BoxMullerLogNormalSampler.java|  1 +
 .../sampling/distribution/ChengBetaSampler.java|  7 +++
 .../rng/sampling/distribution/GaussianSampler.java |  5 +++
 .../InverseTransformParetoSampler.java |  7 +++
 .../distribution/LargeMeanPoissonSampler.java  |  4 +-
 .../sampling/distribution/LogNormalSampler.java|  7 +++
 .../distribution/SmallMeanPoissonSampler.java  |  7 +--
 ...ava => AhrensDieterExponentialSamplerTest.java} | 23 +++---
 ...hrensDieterMarsagliaTsangGammaSamplerTest.java} | 26 ++-
 ...Test.java => BoxMullerGaussianSamplerTest.java} | 28 
 ...est.java => BoxMullerLogNormalSamplerTest.java} | 26 ++-
 ...nSamplerTest.java => ChengBetaSamplerTest.java} | 26 ++-
 .../distribution/ContinuousUniformSamplerTest.java | 51 ++
 ...erTest.java => DiscreteUniformSamplerTest.java} | 34 +--
 ...onSamplerTest.java => GaussianSamplerTest.java} | 29 
 .../distribution/GeometricSamplerTest.java | 17 
 ...java => InverseTransformParetoSamplerTest.java} | 26 ++-
 .../distribution/LargeMeanPoissonSamplerTest.java  | 10 +++--
 ...nSamplerTest.java => LogNormalSamplerTest.java} | 28 +++-
 ...java => RejectionInversionZipfSamplerTest.java} | 26 ++-
 .../distribution/SmallMeanPoissonSamplerTest.java  | 12 +++--
 24 files changed, 241 insertions(+), 178 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterExponentialSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterExponentialSampler.java
index 7927d35..56e57b4 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterExponentialSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterExponentialSampler.java
@@ -64,10 +64,14 @@ public class AhrensDieterExponentialSampler
 /**
  * @param rng Generator of uniformly distributed random numbers.
  * @param mean Mean of this distribution.
+ * @throws IllegalArgumentException if {@code mean <= 0}
  */
 public AhrensDieterExponentialSampler(UniformRandomProvider rng,
   double mean) {
 super(null);
+if (mean <= 0) {
+throw new IllegalArgumentException("mean is not strictly positive: 
" + mean);
+}
 this.rng = rng;
 this.mean = mean;
 }
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
index 42a50e4..946475b 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/AhrensDieterMarsagliaTsangGammaSampler.java
@@ -64,10 +64,17 @@ public class AhrensDieterMarsagliaTsangGammaSampler
  * @param rng Generator of uniformly distributed random numbers.
  * @param alpha Alpha shape parameter of the distribution.
  * @param theta Theta scale parameter of the distribution.
+ * @throws IllegalArgumentException if {@code alpha <= 0} or {@code 
theta <= 0}
  */
 BaseAhrensDieterMarsagliaTsangGammaSampler(UniformRandomProvider rng,
double alpha,
double theta) {
+if (alpha <= 0) {
+throw new IllegalArgumentException("alpha is not strictly 
positive: " + alpha);
+}
+if (theta <= 0) {
+throw new IllegalArgumentException("theta is not strictly 
positive: " + theta);
+}
 this.rng = rng;
  

[commons-rng] 13/21: Merge branch 'update-readme' of https://github.com/aherbert/commons-rng into updatereadme

2019-02-25 Thread aherbert
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 1311c7b934db7f885e0e2230576ac4c40d6ac038
Merge: a71ba4a 7aa35d9
Author: aherbert 
AuthorDate: Mon Feb 25 13:12:35 2019 +

Merge branch 'update-readme' of https://github.com/aherbert/commons-rng 
into updatereadme

 README.md  | 41 ++
 commons-rng-client-api/README.md   | 16 -
 commons-rng-core/README.md | 20 ++-
 commons-rng-examples/README.md | 21 +--
 commons-rng-examples/examples-jmh/README.md| 20 +--
 commons-rng-examples/examples-jpms/README.md   | 20 +--
 .../examples-jpms/jpms-app/README.md   | 16 -
 .../examples-jpms/jpms-lib/README.md   | 16 -
 commons-rng-examples/examples-quadrature/README.md | 20 +--
 commons-rng-examples/examples-sampling/README.md   | 20 +--
 commons-rng-examples/examples-stress/README.md | 20 +--
 commons-rng-sampling/README.md | 16 -
 commons-rng-simple/README.md   | 16 -
 13 files changed, 139 insertions(+), 123 deletions(-)



[commons-rng] 18/21: Track changes.

2019-02-25 Thread aherbert
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 6746242cd87c7af6db3979f39a142b054b07d41b
Author: aherbert 
AuthorDate: Mon Feb 25 13:18:46 2019 +

Track changes.
---
 src/changes/changes.xml | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 94b74d0..14ac2f1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,8 +75,11 @@ re-run tests that fail, and pass the build if they succeed
 within the allotted number of reruns (the test will be marked
 as 'flaky' in the report).
 ">
+  
+Validate parameters for the distribution samplers
+  
   
-""AhrensDieterMarsagliaTsangGammaSampler": Algorithms for small and 
large theta have
+"AhrensDieterMarsagliaTsangGammaSampler": Algorithms for small and 
large theta have
 been delegated to specialised classes.
   
   



[commons-rng] 14/21: Update description in quadrature pom to refer to integration.

2019-02-25 Thread aherbert
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 56bdb01ae96974f6e6e28486f6f6043fb07b4d03
Author: aherbert 
AuthorDate: Mon Feb 25 13:14:31 2019 +

Update description in quadrature pom to refer to integration.
---
 commons-rng-examples/examples-quadrature/README.md | 2 +-
 commons-rng-examples/examples-quadrature/pom.xml   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/commons-rng-examples/examples-quadrature/README.md 
b/commons-rng-examples/examples-quadrature/README.md
index ab24bf7..e82cdd6 100644
--- a/commons-rng-examples/examples-quadrature/README.md
+++ b/commons-rng-examples/examples-quadrature/README.md
@@ -48,7 +48,7 @@ Quadrature example
 [![Maven 
Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-examples-quadrature/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-rng-examples-quadrature/)
 
[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-rng-examples-quadrature/1.2.svg)](https://javadoc.io/doc/org.apache.commons/commons-rng-examples-quadrature/1.2)
 
-Application for calling external tools that perform stringent uniformity tests.
+Contains examples for computing numerical quadrature (integration).
   Code in this module is not part of the public API.
 
 Documentation
diff --git a/commons-rng-examples/examples-quadrature/pom.xml 
b/commons-rng-examples/examples-quadrature/pom.xml
index cb357f8..18b5026 100644
--- a/commons-rng-examples/examples-quadrature/pom.xml
+++ b/commons-rng-examples/examples-quadrature/pom.xml
@@ -31,7 +31,7 @@
   1.3-SNAPSHOT
   Quadrature example
 
-  Application for calling external tools that perform stringent 
uniformity tests.
+  Contains examples for computing numerical quadrature 
(integration).
   Code in this module is not part of the public API.
 
   



[commons-rng] 20/21: Track changes.

2019-02-25 Thread aherbert
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 9ac34c74aa8e5aff882e449df328b31d3111fd14
Author: aherbert 
AuthorDate: Mon Feb 25 13:20:38 2019 +

Track changes.
---
 src/changes/changes.xml | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 14ac2f1..a22da18 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,8 +75,11 @@ re-run tests that fail, and pass the build if they succeed
 within the allotted number of reruns (the test will be marked
 as 'flaky' in the report).
 ">
+  
+Add new JMH benchmark ConstructionPerformance.
+  
   
-Validate parameters for the distribution samplers
+Validate parameters for the distribution samplers.
   
   
 "AhrensDieterMarsagliaTsangGammaSampler": Algorithms for small and 
large theta have



[commons-rng] 15/21: Merge branch 'updatereadme'

2019-02-25 Thread aherbert
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 5d4e8a513294b32e268f6c5a9da11cbb0b3dee09
Merge: a71ba4a 56bdb01
Author: aherbert 
AuthorDate: Mon Feb 25 13:14:56 2019 +

Merge branch 'updatereadme'

Closes #23

 README.md  | 41 ++
 commons-rng-client-api/README.md   | 16 -
 commons-rng-core/README.md | 20 ++-
 commons-rng-examples/README.md | 21 +--
 commons-rng-examples/examples-jmh/README.md| 20 +--
 commons-rng-examples/examples-jpms/README.md   | 20 +--
 .../examples-jpms/jpms-app/README.md   | 16 -
 .../examples-jpms/jpms-lib/README.md   | 16 -
 commons-rng-examples/examples-quadrature/README.md | 22 ++--
 commons-rng-examples/examples-quadrature/pom.xml   |  2 +-
 commons-rng-examples/examples-sampling/README.md   | 20 +--
 commons-rng-examples/examples-stress/README.md | 20 +--
 commons-rng-sampling/README.md | 16 -
 commons-rng-simple/README.md   | 16 -
 14 files changed, 141 insertions(+), 125 deletions(-)



[commons-rng] 17/21: Merge branch 'aherbert-improvement-RNG-71'

2019-02-25 Thread aherbert
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 4d42b1b4e5f131ca2eb6311b255be7d0c4d49b94
Merge: 5d4e8a5 53a87e9
Author: aherbert 
AuthorDate: Mon Feb 25 13:16:55 2019 +

Merge branch 'aherbert-improvement-RNG-71'

Closes #21

 .../AhrensDieterExponentialSampler.java|  4 ++
 .../AhrensDieterMarsagliaTsangGammaSampler.java| 10 
 .../distribution/BoxMullerGaussianSampler.java |  5 ++
 .../distribution/BoxMullerLogNormalSampler.java|  1 +
 .../sampling/distribution/ChengBetaSampler.java|  7 +++
 .../rng/sampling/distribution/GaussianSampler.java |  5 ++
 .../InverseTransformParetoSampler.java |  7 +++
 .../distribution/LargeMeanPoissonSampler.java  |  4 +-
 .../sampling/distribution/LogNormalSampler.java|  7 +++
 .../distribution/SmallMeanPoissonSampler.java  |  7 +--
 .../AhrensDieterExponentialSamplerTest.java| 39 +++
 ...AhrensDieterMarsagliaTsangGammaSamplerTest.java | 54 +
 .../distribution/BoxMullerGaussianSamplerTest.java | 40 
 .../BoxMullerLogNormalSamplerTest.java | 54 +
 .../distribution/ChengBetaSamplerTest.java | 54 +
 .../distribution/ContinuousUniformSamplerTest.java | 51 
 .../distribution/DiscreteUniformSamplerTest.java   | 38 +++
 .../sampling/distribution/GaussianSamplerTest.java | 41 
 .../distribution/GeometricSamplerTest.java | 17 +++
 .../InverseTransformParetoSamplerTest.java | 54 +
 .../distribution/LargeMeanPoissonSamplerTest.java  | 10 ++--
 .../distribution/LogNormalSamplerTest.java | 56 ++
 .../RejectionInversionZipfSamplerTest.java | 54 +
 .../distribution/SmallMeanPoissonSamplerTest.java  | 12 ++---
 24 files changed, 607 insertions(+), 24 deletions(-)



[commons-rng] 12/21: Document use of null RandomGenerator in the distribution samplers tests.

2019-02-25 Thread aherbert
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 a71ba4abc2b514ec0d93ab1f808621a0d5bd5ccf
Author: aherbert 
AuthorDate: Mon Feb 25 13:11:03 2019 +

Document use of null RandomGenerator in the distribution samplers tests.
---
 .../distribution/ContinuousSamplersList.java   | 78 --
 .../distribution/DiscreteSamplersList.java | 44 ++--
 2 files changed, 65 insertions(+), 57 deletions(-)

diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousSamplersList.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousSamplersList.java
index 1cf4313..d94b617 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousSamplersList.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousSamplersList.java
@@ -33,176 +33,180 @@ public class ContinuousSamplersList {
 
 static {
 try {
-// The commons-math distributions are not used for sampling so use 
a null random generator
-org.apache.commons.math3.random.RandomGenerator rng = null;
+// This test uses reference distributions from commons-math3 to 
compute the expected
+// PMF. These distributions have a dual functionality to compute 
the PMF and perform
+// sampling. When no sampling is needed for the created 
distribution, it is advised
+// to pass null as the random generator via the appropriate 
constructors to avoid the
+// additional initialisation overhead.
+org.apache.commons.math3.random.RandomGenerator unusedRng = null;
 
 // List of distributions to test.
 
 // Gaussian ("inverse method").
 final double meanNormal = -123.45;
 final double sigmaNormal = 6.789;
-add(LIST, new 
org.apache.commons.math3.distribution.NormalDistribution(rng, meanNormal, 
sigmaNormal),
+add(LIST, new 
org.apache.commons.math3.distribution.NormalDistribution(unusedRng, meanNormal, 
sigmaNormal),
 RandomSource.create(RandomSource.KISS));
 // Gaussian (DEPRECATED "Box-Muller").
-add(LIST, new 
org.apache.commons.math3.distribution.NormalDistribution(rng, meanNormal, 
sigmaNormal),
+add(LIST, new 
org.apache.commons.math3.distribution.NormalDistribution(unusedRng, meanNormal, 
sigmaNormal),
 new 
BoxMullerGaussianSampler(RandomSource.create(RandomSource.MT), meanNormal, 
sigmaNormal));
 // Gaussian ("Box-Muller").
-add(LIST, new 
org.apache.commons.math3.distribution.NormalDistribution(rng, meanNormal, 
sigmaNormal),
+add(LIST, new 
org.apache.commons.math3.distribution.NormalDistribution(unusedRng, meanNormal, 
sigmaNormal),
 new GaussianSampler(new 
BoxMullerNormalizedGaussianSampler(RandomSource.create(RandomSource.MT)),
 meanNormal, sigmaNormal));
 // Gaussian ("Marsaglia").
-add(LIST, new 
org.apache.commons.math3.distribution.NormalDistribution(rng, meanNormal, 
sigmaNormal),
+add(LIST, new 
org.apache.commons.math3.distribution.NormalDistribution(unusedRng, meanNormal, 
sigmaNormal),
 new GaussianSampler(new 
MarsagliaNormalizedGaussianSampler(RandomSource.create(RandomSource.MT)),
 meanNormal, sigmaNormal));
 // Gaussian ("Ziggurat").
-add(LIST, new 
org.apache.commons.math3.distribution.NormalDistribution(rng, meanNormal, 
sigmaNormal),
+add(LIST, new 
org.apache.commons.math3.distribution.NormalDistribution(unusedRng, meanNormal, 
sigmaNormal),
 new GaussianSampler(new 
ZigguratNormalizedGaussianSampler(RandomSource.create(RandomSource.MT)),
 meanNormal, sigmaNormal));
 
 // Beta ("inverse method").
 final double alphaBeta = 4.3;
 final double betaBeta = 2.1;
-add(LIST, new 
org.apache.commons.math3.distribution.BetaDistribution(rng, alphaBeta, 
betaBeta),
+add(LIST, new 
org.apache.commons.math3.distribution.BetaDistribution(unusedRng, alphaBeta, 
betaBeta),
 RandomSource.create(RandomSource.ISAAC));
 // Beta ("Cheng").
-add(LIST, new 
org.apache.commons.math3.distribution.BetaDistribution(rng, alphaBeta, 
betaBeta),
+add(LIST, new 
org.apache.commons.math3.distribution.BetaDistribution(unusedRng, alphaBeta, 
betaBeta),
 new 
ChengBetaSampler(RandomSource.create(RandomSource.MWC_256), alphaBeta, 
betaBeta));
-   

[commons-rng] 03/21: Fix commons homepage title. Fix type in donate link.

2019-02-25 Thread aherbert
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 af26a0e8b9b8e12b2be21351ab82f4d633392e92
Author: Alex Herbert 
AuthorDate: Sun Feb 17 14:09:00 2019 +

Fix commons homepage title. Fix type in donate link.
---
 README.md | 4 ++--
 commons-rng-client-api/README.md  | 4 ++--
 commons-rng-core/README.md| 4 ++--
 commons-rng-examples/README.md| 4 ++--
 commons-rng-examples/examples-jmh/README.md   | 4 ++--
 commons-rng-examples/examples-jpms/README.md  | 4 ++--
 commons-rng-examples/examples-jpms/jpms-app/README.md | 4 ++--
 commons-rng-examples/examples-jpms/jpms-lib/README.md | 4 ++--
 commons-rng-examples/examples-quadrature/README.md| 4 ++--
 commons-rng-examples/examples-sampling/README.md  | 4 ++--
 commons-rng-examples/examples-stress/README.md| 4 ++--
 commons-rng-sampling/README.md| 4 ++--
 commons-rng-simple/README.md  | 4 ++--
 13 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/README.md b/README.md
index 47af962..aa4d05a 100644
--- a/README.md
+++ b/README.md
@@ -96,12 +96,12 @@ See the `NOTICE.txt` file for required notices and 
attributions.
 
 Donations
 -
-You like Apache Commons RNG? The [donate back to the 
ASF](https://www.apache.org/foundation/contributing.html) to support the 
development.
+You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.org/foundation/contributing.html) to support the 
development.
 
 Additional Resources
 
 
-+ [Apache Commons RNG homepage](https://commons.apache.org/)
++ [Apache Commons homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
 + `#apache-commons` IRC channel on `irc.freenode.org`
diff --git a/commons-rng-client-api/README.md b/commons-rng-client-api/README.md
index 425b7fd..582e59f 100644
--- a/commons-rng-client-api/README.md
+++ b/commons-rng-client-api/README.md
@@ -92,12 +92,12 @@ See the `NOTICE.txt` file for required notices and 
attributions.
 
 Donations
 -
-You like Apache Commons RNG? The [donate back to the 
ASF](https://www.apache.org/foundation/contributing.html) to support the 
development.
+You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.org/foundation/contributing.html) to support the 
development.
 
 Additional Resources
 
 
-+ [Apache Commons RNG homepage](https://commons.apache.org/)
++ [Apache Commons homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
 + `#apache-commons` IRC channel on `irc.freenode.org`
diff --git a/commons-rng-core/README.md b/commons-rng-core/README.md
index 9346025..e865cdc 100644
--- a/commons-rng-core/README.md
+++ b/commons-rng-core/README.md
@@ -96,12 +96,12 @@ See the `NOTICE.txt` file for required notices and 
attributions.
 
 Donations
 -
-You like Apache Commons RNG? The [donate back to the 
ASF](https://www.apache.org/foundation/contributing.html) to support the 
development.
+You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.org/foundation/contributing.html) to support the 
development.
 
 Additional Resources
 
 
-+ [Apache Commons RNG homepage](https://commons.apache.org/)
++ [Apache Commons homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
 + `#apache-commons` IRC channel on `irc.freenode.org`
diff --git a/commons-rng-examples/README.md b/commons-rng-examples/README.md
index 79fddfa..f5206d8 100644
--- a/commons-rng-examples/README.md
+++ b/commons-rng-examples/README.md
@@ -95,12 +95,12 @@ See the `NOTICE.txt` file for required notices and 
attributions.
 
 Donations
 -
-You like Apache Commons RNG? The [donate back to the 
ASF](https://www.apache.org/foundation/contributing.html) to support the 
development.
+You like Apache Commons RNG? Then [donate back to the 
ASF](https://www.apache.org/foundation/contributing.html) to support the 
development.
 
 Additional Resources
 
 
-+ [Apache Commons RNG homepage](https://commons.apache.org/)
++ [Apache Commons homepage](https://commons.apache.org/)
 + [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG)
 + [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
 + `#apache-commons` IRC channel on `irc.freenode.org`
diff --git a/commons-rng-examples/examples-jmh/README.md 
b/commons

[commons-rng] branch master updated (dc0786b -> acda087)

2019-02-26 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from dc0786b  Merge branch 'aherbert-feature-RNG-72'
 new 89ee371  DiscreteProbabilityCollectionSampler: Fix index check from 
binarySearch.
 new acda087  Fix test coverage of DiscreteProbabilityCollectionSampler.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../DiscreteProbabilityCollectionSampler.java  |  3 +-
 .../DiscreteProbabilityCollectionSamplerTest.java  | 56 ++
 2 files changed, 57 insertions(+), 2 deletions(-)



[commons-rng] 02/02: Fix test coverage of DiscreteProbabilityCollectionSampler.

2019-02-26 Thread aherbert
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 acda087dfb76cbc359c1fe74f3397aed52674562
Author: aherbert 
AuthorDate: Tue Feb 26 13:46:07 2019 +

Fix test coverage of DiscreteProbabilityCollectionSampler.
---
 .../DiscreteProbabilityCollectionSamplerTest.java  | 56 ++
 1 file changed, 56 insertions(+)

diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
index 5fb7f77..0df63c6 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
@@ -18,9 +18,13 @@
 package org.apache.commons.rng.sampling;
 
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
 import org.junit.Assert;
 import org.junit.Test;
 import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.core.source64.SplitMix64;
 import org.apache.commons.rng.simple.RandomSource;
 
 /**
@@ -60,6 +64,11 @@ public class DiscreteProbabilityCollectionSamplerTest {
  Arrays.asList(new 
Double[] {1d, 2d}),
  new double[] {0d, 
Double.POSITIVE_INFINITY});
 }
+@Test(expected=IllegalArgumentException.class)
+public void testPrecondition6() {
+new DiscreteProbabilityCollectionSampler(rng,
+ new 
HashMap());
+}
 
 @Test
 public void testSample() {
@@ -84,4 +93,51 @@ public class DiscreteProbabilityCollectionSamplerTest {
 final double variance = sumOfSquares / n - mean * mean;
 Assert.assertEquals(expectedVariance, variance, 2e-3);
 }
+
+
+/**
+ * Edge-case test:
+ * Create a sampler that will return 1 for nextDouble() forcing the binary 
search to
+ * identify the end item of the cumulative probability array.
+ */
+@Test
+public void testSampleWithProbabilityAtLastItem() {
+final List list = Arrays.asList(new Double[] {1d, 2d});
+UniformRandomProvider dummyRng = new SplitMix64(0L) {
+@Override
+public double nextDouble() {
+return 1;
+}
+};
+
+final DiscreteProbabilityCollectionSampler sampler =
+new DiscreteProbabilityCollectionSampler(dummyRng,
+ list,
+ new double[] 
{0.5, 0.5});
+final Double item = sampler.sample();
+Assert.assertEquals(list.get(list.size() - 1), item);
+}
+
+/**
+ * Edge-case test:
+ * Create a sampler that will return over 1 for nextDouble() forcing the 
binary search to
+ * identify insertion at the end of the cumulative probability array
+ */
+@Test
+public void testSampleWithProbabilityPastLastItem() {
+final List list = Arrays.asList(new Double[] {1d, 2d});
+UniformRandomProvider dummyRng = new SplitMix64(0L) {
+@Override
+public double nextDouble() {
+return 1.1;
+}
+};
+
+final DiscreteProbabilityCollectionSampler sampler =
+new DiscreteProbabilityCollectionSampler(dummyRng,
+ list,
+ new double[] 
{0.5, 0.5});
+final Double item = sampler.sample();
+Assert.assertEquals(list.get(list.size() - 1), item);
+}
 }



[commons-rng] 01/02: DiscreteProbabilityCollectionSampler: Fix index check from binarySearch.

2019-02-26 Thread aherbert
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 89ee371d557fc339cc76a91540e870b7e2de4750
Author: aherbert 
AuthorDate: Tue Feb 26 13:14:36 2019 +

DiscreteProbabilityCollectionSampler: Fix index check from binarySearch.

The index cannot be negative after the conversion. -Integer.MIN_VALUE -1
= Integer.MAX_VALUE due to underflow.
---
 .../commons/rng/sampling/DiscreteProbabilityCollectionSampler.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSampler.java
index 8c77da0..f85ff14 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSampler.java
@@ -135,8 +135,7 @@ public class DiscreteProbabilityCollectionSampler {
 index = -index - 1;
 }
 
-if (index >= 0 &&
-index < cumulativeProbabilities.length &&
+if (index < cumulativeProbabilities.length &&
 rand < cumulativeProbabilities[index]) {
 return items.get(index);
 }



[commons-rng] branch master updated: Document preconditions

2019-02-26 Thread aherbert
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 c97825f  Document preconditions
c97825f is described below

commit c97825f6afde2692282b41542e024d100c5af237
Author: aherbert 
AuthorDate: Tue Feb 26 13:54:20 2019 +

Document preconditions
---
 .../rng/sampling/DiscreteProbabilityCollectionSamplerTest.java| 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
index 0df63c6..92a7412 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
@@ -36,36 +36,42 @@ public class DiscreteProbabilityCollectionSamplerTest {
 
 @Test(expected=IllegalArgumentException.class)
 public void testPrecondition1() {
+// Size mismatch
 new DiscreteProbabilityCollectionSampler(rng,
  Arrays.asList(new 
Double[] {1d, 2d}),
  new double[] {0d});
 }
 @Test(expected=IllegalArgumentException.class)
 public void testPrecondition2() {
+// Negative probability
 new DiscreteProbabilityCollectionSampler(rng,
  Arrays.asList(new 
Double[] {1d, 2d}),
  new double[] {0d, 
-1d});
 }
 @Test(expected=IllegalArgumentException.class)
 public void testPrecondition3() {
+// Probabilities do not sum above 0
 new DiscreteProbabilityCollectionSampler(rng,
  Arrays.asList(new 
Double[] {1d, 2d}),
  new double[] {0d, 
0d});
 }
 @Test(expected=IllegalArgumentException.class)
 public void testPrecondition4() {
+// NaN probability
 new DiscreteProbabilityCollectionSampler(rng,
  Arrays.asList(new 
Double[] {1d, 2d}),
  new double[] {0d, 
Double.NaN});
 }
 @Test(expected=IllegalArgumentException.class)
 public void testPrecondition5() {
+// Infinite probability
 new DiscreteProbabilityCollectionSampler(rng,
  Arrays.asList(new 
Double[] {1d, 2d}),
  new double[] {0d, 
Double.POSITIVE_INFINITY});
 }
 @Test(expected=IllegalArgumentException.class)
 public void testPrecondition6() {
+// Empty Map not allowed
 new DiscreteProbabilityCollectionSampler(rng,
  new 
HashMap());
 }
@@ -121,7 +127,7 @@ public class DiscreteProbabilityCollectionSamplerTest {
 /**
  * Edge-case test:
  * Create a sampler that will return over 1 for nextDouble() forcing the 
binary search to
- * identify insertion at the end of the cumulative probability array
+ * identify insertion at the end of the cumulative probability array.
  */
 @Test
 public void testSampleWithProbabilityPastLastItem() {



[commons-rng] branch master updated: DiscreteProbabilityCollectionSamplerTest: Fix test for last item.

2019-02-26 Thread aherbert
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 5aed399  DiscreteProbabilityCollectionSamplerTest: Fix test for last 
item.
5aed399 is described below

commit 5aed399de0aa2acce13ee74479ef2b6f5e4f4cff
Author: aherbert 
AuthorDate: Tue Feb 26 15:04:41 2019 +

DiscreteProbabilityCollectionSamplerTest: Fix test for last item.

The last item order depends on the entry set of the Map. This can change
so fix the test to handle this.
---
 .../DiscreteProbabilityCollectionSamplerTest.java  | 53 --
 1 file changed, 29 insertions(+), 24 deletions(-)

diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
index 92a7412..b02bde5 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSamplerTest.java
@@ -100,7 +100,6 @@ public class DiscreteProbabilityCollectionSamplerTest {
 Assert.assertEquals(expectedVariance, variance, 2e-3);
 }
 
-
 /**
  * Edge-case test:
  * Create a sampler that will return 1 for nextDouble() forcing the binary 
search to
@@ -108,20 +107,7 @@ public class DiscreteProbabilityCollectionSamplerTest {
  */
 @Test
 public void testSampleWithProbabilityAtLastItem() {
-final List list = Arrays.asList(new Double[] {1d, 2d});
-UniformRandomProvider dummyRng = new SplitMix64(0L) {
-@Override
-public double nextDouble() {
-return 1;
-}
-};
-
-final DiscreteProbabilityCollectionSampler sampler =
-new DiscreteProbabilityCollectionSampler(dummyRng,
- list,
- new double[] 
{0.5, 0.5});
-final Double item = sampler.sample();
-Assert.assertEquals(list.get(list.size() - 1), item);
+sampleWithProbabilityForLastItem(false);
 }
 
 /**
@@ -131,19 +117,38 @@ public class DiscreteProbabilityCollectionSamplerTest {
  */
 @Test
 public void testSampleWithProbabilityPastLastItem() {
-final List list = Arrays.asList(new Double[] {1d, 2d});
-UniformRandomProvider dummyRng = new SplitMix64(0L) {
-@Override
-public double nextDouble() {
-return 1.1;
-}
+sampleWithProbabilityForLastItem(true);
+}
+
+private static void sampleWithProbabilityForLastItem(boolean pastLast) {
+// Ensure the samples pick probability 0 (the first item) and then
+// a probability (for the second item) that hits an edge case.
+final double probability = pastLast ? 1.1 : 1;
+final UniformRandomProvider dummyRng = new UniformRandomProvider() {
+int count;
+public long nextLong(long n) { return 0; }
+public long nextLong() { return 0; }
+public int nextInt(int n) { return 0; }
+public int nextInt() { return 0; }
+public float nextFloat() { return 0; }
+// Return 0 then the given probability
+public double nextDouble() { return (count++ == 0) ? 0 : 
probability; }
+public void nextBytes(byte[] bytes, int start, int len) {}
+public void nextBytes(byte[] bytes) {}
+public boolean nextBoolean() { return false; }
 };
 
+final List items = Arrays.asList(new Double[] {1d, 2d});
 final DiscreteProbabilityCollectionSampler sampler =
 new DiscreteProbabilityCollectionSampler(dummyRng,
- list,
+ items,
  new double[] 
{0.5, 0.5});
-final Double item = sampler.sample();
-Assert.assertEquals(list.get(list.size() - 1), item);
+final Double item1 = sampler.sample();
+final Double item2 = sampler.sample();
+// Check they are in the list
+Assert.assertTrue("Sample item1 is not from the list", 
items.contains(item1));
+Assert.assertTrue("Sample item2 is not from the list", 
items.contains(item2));
+// Test the two samples are different items
+Assert.assertNotSame("Item1 and 2 should be different", item1, item2);
 }
 }



[commons-rng] branch master updated: Fix UnitSphereSampler test coverage.

2019-02-26 Thread aherbert
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 0cf148a  Fix UnitSphereSampler test coverage.
0cf148a is described below

commit 0cf148a8e692eee719d8250bfe17a2de3afe4788
Author: aherbert 
AuthorDate: Tue Feb 26 15:12:01 2019 +

Fix UnitSphereSampler test coverage.
---
 .../commons/rng/sampling/UnitSphereSamplerTest.java  | 16 
 1 file changed, 16 insertions(+)

diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
index fb4ac08..5d32105 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
@@ -20,6 +20,7 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.apache.commons.rng.simple.RandomSource;
 import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.core.source64.SplitMix64;
 
 /**
  * Test for {@link UnitSphereSampler}.
@@ -79,6 +80,21 @@ public class UnitSphereSamplerTest {
 new UnitSphereSampler(1, bad).nextVector();
 }
 
+/** Cf. RNG-55. */
+@Test
+public void testBadProvider1ThenGoodProvider() {
+// Create a provider that will create a bad first sample but then 
recover.
+// This checks recursion will return a good value.
+final UniformRandomProvider bad = new SplitMix64(0L) {
+int count;
+public long nextLong() { return (count++ == 0) ? 0 : 
super.nextLong(); }
+public double nextDouble() { return (count++ == 0) ? 0 : 
super.nextDouble(); }
+};
+
+final double[] vector = new UnitSphereSampler(1, bad).nextVector();
+Assert.assertEquals(1, vector.length);
+}
+
 /**
  * @return the length (L2-norm) of given vector.
  */



[commons-rng] 01/03: GenerationPerformance fix javadoc typo

2019-02-27 Thread aherbert
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 12df8780fad94c60940c8146f5a0287937426f37
Author: aherbert 
AuthorDate: Wed Feb 27 13:33:22 2019 +

GenerationPerformance fix javadoc typo
---
 .../java/org/apache/commons/rng/examples/jmh/GenerationPerformance.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/GenerationPerformance.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/GenerationPerformance.java
index c22cf7c..82a82e8 100644
--- 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/GenerationPerformance.java
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/GenerationPerformance.java
@@ -80,7 +80,7 @@ public class GenerationPerformance {
 return provider;
 }
 
-/** Intantiates generator. */
+/** Instantiates generator. */
 @Setup
 public void setup() {
 final RandomSource randomSource = 
RandomSource.valueOf(randomSourceName);



[commons-rng] 02/03: Update JMH version to latest (1.13 to 1.21).

2019-02-27 Thread aherbert
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 68cfb49f53b72bb3e4b4114a817246abc04f941d
Author: aherbert 
AuthorDate: Wed Feb 27 14:06:35 2019 +

Update JMH version to latest (1.13 to 1.21).
---
 commons-rng-examples/examples-jmh/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commons-rng-examples/examples-jmh/pom.xml 
b/commons-rng-examples/examples-jmh/pom.xml
index e935fa7..9d7e629 100644
--- a/commons-rng-examples/examples-jmh/pom.xml
+++ b/commons-rng-examples/examples-jmh/pom.xml
@@ -68,7 +68,7 @@
 ${basedir}/../..
 
 
-1.13
+1.21
 benchmarks
 1.6.0
   



[commons-rng] 03/03: ConstructionPerformance: added generation of numbers after construction.

2019-02-27 Thread aherbert
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 59ab70d300ca1221cb6512faf698be8c1c68b163
Author: aherbert 
AuthorDate: Wed Feb 27 14:24:55 2019 +

ConstructionPerformance: added generation of numbers after construction.

No RNG is constructed without using it so the benchmark now exercises
the RNG. Also added a method to construct using a long seed.
---
 .../rng/examples/jmh/ConstructionPerformance.java  | 83 --
 1 file changed, 62 insertions(+), 21 deletions(-)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
index 4c201f3..9576c39 100644
--- 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
@@ -37,6 +37,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.core.source32.ISAACRandom;
+import org.apache.commons.rng.core.source32.IntProvider;
 import org.apache.commons.rng.core.source32.JDKRandom;
 import org.apache.commons.rng.core.source32.KISSRandom;
 import org.apache.commons.rng.core.source32.MersenneTwister;
@@ -392,12 +393,39 @@ public class ConstructionPerformance {
 }
 
 /**
+ * Number of random values to generate after construction.
+ */
+@Param({"0", "1", "100", "1"})
+private int numValues;
+
+/**
+ * Consume the generator and run the native generation method a set number 
of times.
+ *
+ * @param bh Data sink.
+ * @param rng the random generator
+ */
+private void runGenerator(Blackhole bh, UniformRandomProvider rng) {
+bh.consume(rng);
+// For fairness this should run when no values are generated
+if (rng instanceof IntProvider) {
+for (int i = numValues; i-- != 0; ) {
+bh.consume(rng.nextInt());
+}
+} else {
+// Assume a long provider
+for (int i = numValues; i-- != 0; ) {
+bh.consume(rng.nextLong());
+}
+}
+}
+
+/**
  * @param bh Data sink.
  */
 @Benchmark
 public void newJDKRandom(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-bh.consume(new JDKRandom(LONG_SEEDS[i]));
+runGenerator(bh, new JDKRandom(LONG_SEEDS[i]));
 }
 }
 
@@ -407,7 +435,7 @@ public class ConstructionPerformance {
 @Benchmark
 public void newWell512a(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-bh.consume(new Well512a(INT_ARRAY_SEEDS[i]));
+runGenerator(bh, new Well512a(INT_ARRAY_SEEDS[i]));
 }
 }
 
@@ -417,7 +445,7 @@ public class ConstructionPerformance {
 @Benchmark
 public void newWell1024a(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-bh.consume(new Well1024a(INT_ARRAY_SEEDS[i]));
+runGenerator(bh, new Well1024a(INT_ARRAY_SEEDS[i]));
 }
 }
 
@@ -427,7 +455,7 @@ public class ConstructionPerformance {
 @Benchmark
 public void newWell19937a(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-bh.consume(new Well19937a(INT_ARRAY_SEEDS[i]));
+runGenerator(bh, new Well19937a(INT_ARRAY_SEEDS[i]));
 }
 }
 
@@ -437,7 +465,7 @@ public class ConstructionPerformance {
 @Benchmark
 public void newWell19937c(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-bh.consume(new Well19937c(INT_ARRAY_SEEDS[i]));
+runGenerator(bh, new Well19937c(INT_ARRAY_SEEDS[i]));
 }
 }
 
@@ -447,7 +475,7 @@ public class ConstructionPerformance {
 @Benchmark
 public void newWell44497a(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-bh.consume(new Well44497a(INT_ARRAY_SEEDS[i]));
+runGenerator(bh, new Well44497a(INT_ARRAY_SEEDS[i]));
 }
 }
 
@@ -457,7 +485,7 @@ public class ConstructionPerformance {
 @Benchmark
 public void newWell44497b(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-bh.consume(new Well44497b(INT_ARRAY_SEEDS[i]));
+runGenerator(bh, new Well44497b(INT_ARRAY_SEEDS[i]));
 }
 }
 
@@ -467,7 +495,7 @@ public class ConstructionPerformance {
 @Benchmark
 public void newMersenneTwister(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-bh.consume(new MersenneTwister(INT_ARRAY_SEEDS[i]));
+runGenerator(bh, new MersenneTwister(INT_ARRAY_

[commons-rng] branch master updated (0cf148a -> 59ab70d)

2019-02-27 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from 0cf148a  Fix UnitSphereSampler test coverage.
 new 12df878  GenerationPerformance fix javadoc typo
 new 68cfb49  Update JMH version to latest (1.13 to 1.21).
 new 59ab70d  ConstructionPerformance: added generation of numbers after 
construction.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 commons-rng-examples/examples-jmh/pom.xml  |  2 +-
 .../rng/examples/jmh/ConstructionPerformance.java  | 83 --
 .../rng/examples/jmh/GenerationPerformance.java|  2 +-
 3 files changed, 64 insertions(+), 23 deletions(-)



[commons-rng] branch master updated: ConstructionPerformance: Added Javadoc about purpose of the benchmark.

2019-02-27 Thread aherbert
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 3a4b6db  ConstructionPerformance: Added Javadoc about purpose of the 
benchmark.
3a4b6db is described below

commit 3a4b6dbe86d25e38a3d665f517e7e233ca64b4a9
Author: aherbert 
AuthorDate: Wed Feb 27 14:58:47 2019 +

ConstructionPerformance: Added Javadoc about purpose of the benchmark.

Removed the generation of values as this is done by
GenerationPerformance. Inclusion in this class is redundant.
---
 .../rng/examples/jmh/ConstructionPerformance.java  | 89 +-
 1 file changed, 36 insertions(+), 53 deletions(-)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
index 9576c39..45fe79e 100644
--- 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
@@ -37,7 +37,6 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.core.source32.ISAACRandom;
-import org.apache.commons.rng.core.source32.IntProvider;
 import org.apache.commons.rng.core.source32.JDKRandom;
 import org.apache.commons.rng.core.source32.KISSRandom;
 import org.apache.commons.rng.core.source32.MersenneTwister;
@@ -57,8 +56,20 @@ import org.apache.commons.rng.simple.RandomSource;
 import 
org.apache.commons.rng.simple.internal.ProviderBuilder.RandomSourceInternal;
 
 /**
- * Executes a benchmark to compare the speed of construction of random number
- * providers.
+ * Executes a benchmark to compare the speed of construction of random number 
providers.
+ *
+ * Note that random number providers are created and then used. Thus the 
construction time must
+ * be analysed together with the run time performance benchmark (see
+ * {@link GenerationPerformance}).
+ *
+ * 
+ * [Total time] = [Construction time] + [Run time]
+ * 
+ *
+ * Selection of a suitable random number provider based on construction 
speed should consider
+ * when the construction time is a large fraction of the run time. In the 
majority of cases the
+ * run time will be the largest component of the total time and the provider 
should be selected
+ * based on its other properties such as the period, statistical randomness 
and speed.
  */
 @BenchmarkMode(Mode.AverageTime)
 @OutputTimeUnit(TimeUnit.MICROSECONDS)
@@ -393,39 +404,12 @@ public class ConstructionPerformance {
 }
 
 /**
- * Number of random values to generate after construction.
- */
-@Param({"0", "1", "100", "1"})
-private int numValues;
-
-/**
- * Consume the generator and run the native generation method a set number 
of times.
- *
- * @param bh Data sink.
- * @param rng the random generator
- */
-private void runGenerator(Blackhole bh, UniformRandomProvider rng) {
-bh.consume(rng);
-// For fairness this should run when no values are generated
-if (rng instanceof IntProvider) {
-for (int i = numValues; i-- != 0; ) {
-bh.consume(rng.nextInt());
-}
-} else {
-// Assume a long provider
-for (int i = numValues; i-- != 0; ) {
-bh.consume(rng.nextLong());
-}
-}
-}
-
-/**
  * @param bh Data sink.
  */
 @Benchmark
 public void newJDKRandom(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-runGenerator(bh, new JDKRandom(LONG_SEEDS[i]));
+bh.consume(new JDKRandom(LONG_SEEDS[i]));
 }
 }
 
@@ -435,7 +419,7 @@ public class ConstructionPerformance {
 @Benchmark
 public void newWell512a(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-runGenerator(bh, new Well512a(INT_ARRAY_SEEDS[i]));
+bh.consume(new Well512a(INT_ARRAY_SEEDS[i]));
 }
 }
 
@@ -445,7 +429,7 @@ public class ConstructionPerformance {
 @Benchmark
 public void newWell1024a(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-runGenerator(bh, new Well1024a(INT_ARRAY_SEEDS[i]));
+bh.consume(new Well1024a(INT_ARRAY_SEEDS[i]));
 }
 }
 
@@ -455,7 +439,7 @@ public class ConstructionPerformance {
 @Benchmark
 public void newWell19937a(Blackhole bh) {
 for (int i = 0; i < SEEDS; i++) {
-runGenerator(bh, new Well19937a(INT_ARRAY_SEEDS[i]));
+bh.consume(new Well19937a(INT_ARRAY_SEEDS[i]));

[commons-rng] 01/04: RNG-74: DiscreteUniformSampler can be optimised for the algorithm

2019-02-28 Thread aherbert
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 2112fa3d258a827cba42efbea15743dd64e0225a
Author: aherbert 
AuthorDate: Tue Feb 26 14:33:17 2019 +

RNG-74: DiscreteUniformSampler can be optimised for the algorithm
---
 .../distribution/DiscreteUniformSampler.java   | 134 -
 1 file changed, 107 insertions(+), 27 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteUniformSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteUniformSampler.java
index 54442a0..00e308b 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteUniformSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteUniformSampler.java
@@ -27,12 +27,103 @@ import org.apache.commons.rng.UniformRandomProvider;
 public class DiscreteUniformSampler
 extends SamplerBase
 implements DiscreteSampler {
-/** Lower bound. */
-private final int lower;
-/** Upper bound. */
-private final int upper;
-/** Underlying source of randomness. */
-private final UniformRandomProvider rng;
+
+/** The appropriate uniform sampler for the parameters. */
+private final DiscreteSampler delegate;
+
+/**
+ * Base class for a sampler from a discrete uniform distribution.
+ */
+private abstract static class AbstractDiscreteUniformSampler
+implements DiscreteSampler {
+
+/** Underlying source of randomness. */
+protected final UniformRandomProvider rng;
+/** Lower bound. */
+protected final int lower;
+
+/**
+ * @param rng Generator of uniformly distributed random numbers.
+ * @param lower Lower bound (inclusive) of the distribution.
+ */
+AbstractDiscreteUniformSampler(UniformRandomProvider rng,
+   int lower) {
+this.rng = rng;
+this.lower = lower;
+}
+
+/** {@inheritDoc} */
+@Override
+public String toString() {
+return "Uniform deviate [" + rng.toString() + "]";
+}
+}
+
+/**
+ * Discrete uniform distribution sampler when the range between lower and 
upper is small
+ * enough to fit in a positive integer.
+ */
+private static class SmallRangeDiscreteUniformSampler
+extends AbstractDiscreteUniformSampler {
+
+/** Maximum range of the sample from the lower bound (exclusive). */
+private final int range;
+
+/**
+ * @param rng Generator of uniformly distributed random numbers.
+ * @param lower Lower bound (inclusive) of the distribution.
+ * @param range Maximum range of the sample from the lower bound 
(exclusive).
+ */
+SmallRangeDiscreteUniformSampler(UniformRandomProvider rng,
+ int lower,
+ int range) {
+super(rng, lower);
+this.range = range;
+}
+
+@Override
+public int sample() {
+return lower + rng.nextInt(range);
+}
+}
+
+/**
+ * Discrete uniform distribution sampler when the range between lower and 
upper is too large
+ * to fit in a positive integer.
+ */
+private static class LargeRangeDiscreteUniformSampler
+extends AbstractDiscreteUniformSampler {
+
+/** Upper bound. */
+private final int upper;
+
+/**
+ * @param rng Generator of uniformly distributed random numbers.
+ * @param lower Lower bound (inclusive) of the distribution.
+ * @param upper Upper bound (inclusive) of the distribution.
+ */
+LargeRangeDiscreteUniformSampler(UniformRandomProvider rng,
+ int lower,
+ int upper) {
+super(rng, lower);
+this.upper = upper;
+}
+
+@Override
+public int sample() {
+// Use a simple rejection method.
+// This is used when (upper-lower) >= Integer.MAX_VALUE.
+// This will loop on average 2 times in the worst case scenario
+// when (upper-lower) == Integer.MAX_VALUE.
+while (true) {
+final int r = rng.nextInt();
+if (r >= lower &&
+r <= upper) {
+return r;
+}
+}
+}
+}
 
 /**
  * @param rng Generator of uniformly distributed random numbers.
@@ -44,39 +135,28 @@ public class DiscreteUniformSampler
   int lower,
  

[commons-rng] 02/04: Merge branch 'improvement-RNG-74' of https://github.com/aherbert/commons-rng into aherbert-improvement-RNG-74

2019-02-28 Thread aherbert
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 5840be0bd157eedeadaa0e60b5ff513eaa6c8bd8
Merge: 3a4b6db 2112fa3
Author: aherbert 
AuthorDate: Thu Feb 28 17:36:29 2019 +

Merge branch 'improvement-RNG-74' of 
https://github.com/aherbert/commons-rng into aherbert-improvement-RNG-74

 .../distribution/DiscreteUniformSampler.java   | 134 -
 1 file changed, 107 insertions(+), 27 deletions(-)



[commons-rng] branch master updated (3a4b6db -> fcaf9e3)

2019-02-28 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from 3a4b6db  ConstructionPerformance: Added Javadoc about purpose of the 
benchmark.
 new 2112fa3  RNG-74: DiscreteUniformSampler can be optimised for the 
algorithm
 new 5840be0  Merge branch 'improvement-RNG-74' of 
https://github.com/aherbert/commons-rng into aherbert-improvement-RNG-74
 new 529b52c  Merge branch 'aherbert-improvement-RNG-74'
 new fcaf9e3  Track changes.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../distribution/DiscreteUniformSampler.java   | 134 -
 src/changes/changes.xml|   4 +
 2 files changed, 111 insertions(+), 27 deletions(-)



[commons-rng] 03/04: Merge branch 'aherbert-improvement-RNG-74'

2019-02-28 Thread aherbert
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 529b52c51f04f3260e1a0fcd0435c9f0136762fe
Merge: 3a4b6db 5840be0
Author: aherbert 
AuthorDate: Thu Feb 28 17:37:06 2019 +

Merge branch 'aherbert-improvement-RNG-74'

Closes #24

 .../distribution/DiscreteUniformSampler.java   | 134 -
 1 file changed, 107 insertions(+), 27 deletions(-)



[commons-rng] 04/04: Track changes.

2019-02-28 Thread aherbert
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 fcaf9e370f2548a4baac306995f418ab8c0ae4bf
Author: aherbert 
AuthorDate: Thu Feb 28 17:38:51 2019 +

Track changes.
---
 src/changes/changes.xml | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a22da18..e49e200 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,6 +75,10 @@ re-run tests that fail, and pass the build if they succeed
 within the allotted number of reruns (the test will be marked
 as 'flaky' in the report).
 ">
+  
+"DiscreteUniformSampler": Algorithms for small and large integer 
ranges have
+been delegated to specialised classes.
+  
   
 Add new JMH benchmark ConstructionPerformance.
   



[commons-rng] branch master updated: ConstructionPerformance: Fix pre-allocation of single seed arrays.

2019-03-01 Thread aherbert
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 cf2ba48  ConstructionPerformance: Fix pre-allocation of single seed 
arrays.
cf2ba48 is described below

commit cf2ba480595df791b7103d0bf75f261ddfa098b4
Author: Alex Herbert 
AuthorDate: Fri Mar 1 20:57:22 2019 +

ConstructionPerformance: Fix pre-allocation of single seed arrays.
---
 .../apache/commons/rng/examples/jmh/ConstructionPerformance.java| 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
index 45fe79e..ba732e0 100644
--- 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/ConstructionPerformance.java
@@ -76,7 +76,7 @@ import 
org.apache.commons.rng.simple.internal.ProviderBuilder.RandomSourceIntern
 @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
 @State(Scope.Benchmark)
-@Fork(value = 1, jvmArgs = { "-server", "-Xms128M", "-Xmx128M" })
+@Fork(value = 1, jvmArgs = { "-server", "-Xms512M", "-Xmx512M" })
 public class ConstructionPerformance {
 
 /** The number of different constructor seeds. */
@@ -111,8 +111,8 @@ public class ConstructionPerformance {
 longArray[j] = rng.nextLong();
 intArray[j] = (int) longArray[j];
 }
-LONG_SEEDS[i] = longArray[i];
-INTEGER_SEEDS[i] = intArray[i];
+LONG_SEEDS[i] = longArray[0];
+INTEGER_SEEDS[i] = intArray[0];
 LONG_ARRAY_SEEDS[i] = longArray;
 INT_ARRAY_SEEDS[i] = intArray;
 BYTE_ARRAY_SEEDS[i] = NumberFactory.makeByteArray(longArray);



[commons-rng] 01/02: UnitSphereSamplerTest: Test to show any normSq value after 0 is valid.

2019-03-03 Thread aherbert
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 52858ebe5277184a46c2d7fecfe55ea907d3c2ea
Author: Alex Herbert 
AuthorDate: Sun Mar 3 16:22:20 2019 +

UnitSphereSamplerTest: Test to show any normSq value after 0 is valid.
---
 .../commons/rng/sampling/UnitSphereSamplerTest.java   | 15 +++
 1 file changed, 15 insertions(+)

diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
index 5d32105..0d64d26 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/UnitSphereSamplerTest.java
@@ -96,6 +96,21 @@ public class UnitSphereSamplerTest {
 }
 
 /**
+ * Test to demonstrate that using floating-point equality of the norm 
squared with
+ * zero is valid. Any norm squared after zero should produce a valid 
scaling factor.
+ */
+@Test
+public void testNextNormSquaredAfterZeroIsValid() {
+// The sampler explicitly handles length == 0 using recursion.
+// Anything above zero should be valid.
+final double normSq = Math.nextAfter(0, 1);
+// Map to the scaling factor
+final double f = 1 / Math.sqrt(normSq);
+// As long as this is finite positive then the sampler is valid
+Assert.assertTrue(f > 0 && f <= Double.MAX_VALUE);
+}
+
+/**
  * @return the length (L2-norm) of given vector.
  */
 private static double length(double[] vector) {



[commons-rng] 02/02: GeometricSamplerTest: Test to show probability of success < 1 is valid.

2019-03-03 Thread aherbert
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 c947e72f30028e3094445bd3072cfb9684c54811
Author: Alex Herbert 
AuthorDate: Sun Mar 3 16:29:07 2019 +

GeometricSamplerTest: Test to show probability of success < 1 is valid.
---
 .../sampling/distribution/GeometricSamplerTest.java   | 19 +++
 1 file changed, 19 insertions(+)

diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
index a1d424c..b3bab01 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/GeometricSamplerTest.java
@@ -40,6 +40,25 @@ public class GeometricSamplerTest {
 }
 
 /**
+ * Test to demonstrate that any probability of success under one produces 
a valid
+ * mean for the exponential distribution.
+ */
+@Test
+public void testProbabilityOfSuccessUnderOneIsValid() {
+// The sampler explicitly handles probabilityOfSuccess == 1 as an edge 
case.
+// Anything under it should be valid for sampling from an 
ExponentialDistribution.
+final double probabilityOfSuccess = Math.nextAfter(1, -1);
+// Map to the mean
+final double exponentialMean = 1.0 / 
(-Math.log1p(-probabilityOfSuccess));
+// As long as this is finite positive then the sampler is valid
+Assert.assertTrue(exponentialMean > 0 && exponentialMean <= 
Double.MAX_VALUE);
+// The internal exponential sampler validates the mean so demonstrate 
creating a
+// geometric sampler does not throw.
+final UniformRandomProvider rng = 
RandomSource.create(RandomSource.SPLIT_MIX_64);
+new GeometricSampler(rng, probabilityOfSuccess);
+}
+
+/**
  * Test the edge case where the probability of success is 1 since it uses 
a different
  * {@link Object#toString()} method to the normal case tested elsewhere.
  */



[commons-rng] branch master updated (14871a9 -> c947e72)

2019-03-03 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from 14871a9  Nits.
 new 52858eb  UnitSphereSamplerTest: Test to show any normSq value after 0 
is valid.
 new c947e72  GeometricSamplerTest: Test to show probability of success < 1 
is valid.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/rng/sampling/UnitSphereSamplerTest.java   | 15 +++
 .../sampling/distribution/GeometricSamplerTest.java   | 19 +++
 2 files changed, 34 insertions(+)



[commons-rng] branch master updated: Added sampling InternalUtilsTest.

2019-03-03 Thread aherbert
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 e27f4cf  Added sampling InternalUtilsTest.
e27f4cf is described below

commit e27f4cfb0a80e639c1f319e6c237fc37af8d3b42
Author: Alex Herbert 
AuthorDate: Sun Mar 3 23:45:29 2019 +

Added sampling InternalUtilsTest.
---
 .../rng/sampling/distribution/InternalUtils.java   |  8 +-
 .../sampling/distribution/InternalUtilsTest.java   | 88 ++
 2 files changed, 92 insertions(+), 4 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
index 287cc8f..d234440 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
@@ -39,8 +39,8 @@ class InternalUtils { // Class is package-private on purpose; 
do not make it pub
 /**
  * @param n Argument.
  * @return {@code n!}
- * @throws IllegalArgumentException if the result is too large to be 
represented
- * by a {@code long} (i.e. if {@code n > 20}).
+ * @throws IndexOutOfBoundsException if the result is too large to be 
represented
+ * by a {@code long} (i.e. if {@code n > 20}), or {@code n} is negative.
  */
 public static long factorial(int n)  {
 return FACTORIALS[n];
@@ -64,7 +64,7 @@ class InternalUtils { // Class is package-private on purpose; 
do not make it pub
  *
  * @param numValues Number of values of the function to compute.
  * @param cache Existing cache.
- * @throw IllegalArgumentException if {@code numValues < 0}.
+ * @throw NegativeArraySizeException if {@code numValues < 0}.
  */
 private FactorialLog(int numValues,
  double[] cache) {
@@ -112,7 +112,7 @@ class InternalUtils { // Class is package-private on 
purpose; do not make it pub
  *
  * @param n Argument.
  * @return {@code log(n!)}.
- * @throws IllegalArgumentException if {@code n < 0}.
+ * @throw IndexOutOfBoundsException if {@code numValues < 0}.
  */
 public double value(final int n) {
 // Use cache of precomputed values.
diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
new file mode 100644
index 000..d1a3b6a
--- /dev/null
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.sampling.distribution;
+
+import org.apache.commons.math3.special.Gamma;
+import org.apache.commons.rng.sampling.distribution.InternalUtils.FactorialLog;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test for the {@link InternalUtils}.
+ */
+public class InternalUtilsTest {
+/** The maximum value for n! that is representable as a long. */
+private static final int MAX_REPRESENTABLE = 20;
+
+@Test
+public void testFactorial() {
+Assert.assertEquals(1L, InternalUtils.factorial(0));
+long result = 1;
+for (int n = 1; n <= MAX_REPRESENTABLE; n++) {
+result *= n;
+Assert.assertEquals(result, InternalUtils.factorial(n));
+}
+}
+
+@Test(expected = IndexOutOfBoundsException.class)
+public void testFactorialThrowsWhenNegative() {
+InternalUtils.factorial(-1);
+}
+
+@Test(expected = IndexOutOfBoundsException.class)
+public void testFactorialThrowsWhenNotRepresentableAsLong() {
+InternalUtils.factorial(MAX_REPRESENTABLE + 1);
+}
+
+@Test
+public void testFactorialLog() {

[commons-rng] 02/02: InternalUtilsTest: Test for NegativeArraySizeException

2019-03-03 Thread aherbert
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 fccc73e3eb62f57cb0f03b1e52d7c7499aa4112a
Author: Alex Herbert 
AuthorDate: Sun Mar 3 23:50:04 2019 +

InternalUtilsTest: Test for NegativeArraySizeException
---
 .../apache/commons/rng/sampling/distribution/InternalUtilsTest.java  | 5 +
 1 file changed, 5 insertions(+)

diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
index d1a3b6a..86f41de 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
@@ -85,4 +85,9 @@ public class InternalUtilsTest {
 public void testLogFactorialThrowsWhenNegative() {
 FactorialLog.create().value(-1);
 }
+
+@Test(expected = NegativeArraySizeException.class)
+public void testLogFactorialWithCacheThrowsWhenNegative() {
+FactorialLog.create().withCache(-1);
+}
 }



[commons-rng] branch master updated (e27f4cf -> fccc73e)

2019-03-03 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from e27f4cf  Added sampling InternalUtilsTest.
 new 5916d2d  InternalUtils: fix javadoc @throws tags
 new fccc73e  InternalUtilsTest: Test for NegativeArraySizeException

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/commons/rng/sampling/distribution/InternalUtils.java  | 4 ++--
 .../apache/commons/rng/sampling/distribution/InternalUtilsTest.java  | 5 +
 2 files changed, 7 insertions(+), 2 deletions(-)



[commons-rng] 01/02: InternalUtils: fix javadoc @throws tags

2019-03-03 Thread aherbert
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 5916d2d14ec1ccb9c65af740b5d7e418a19ecfdf
Author: Alex Herbert 
AuthorDate: Sun Mar 3 23:49:42 2019 +

InternalUtils: fix javadoc @throws tags
---
 .../org/apache/commons/rng/sampling/distribution/InternalUtils.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
index d234440..5a9e11b 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
@@ -64,7 +64,7 @@ class InternalUtils { // Class is package-private on purpose; 
do not make it pub
  *
  * @param numValues Number of values of the function to compute.
  * @param cache Existing cache.
- * @throw NegativeArraySizeException if {@code numValues < 0}.
+ * @throws NegativeArraySizeException if {@code numValues < 0}.
  */
 private FactorialLog(int numValues,
  double[] cache) {
@@ -112,7 +112,7 @@ class InternalUtils { // Class is package-private on 
purpose; do not make it pub
  *
  * @param n Argument.
  * @return {@code log(n!)}.
- * @throw IndexOutOfBoundsException if {@code numValues < 0}.
+ * @throws IndexOutOfBoundsException if {@code numValues < 0}.
  */
 public double value(final int n) {
 // Use cache of precomputed values.



[commons-rng] 06/10: RNG-79: Modify benchmark to use uniform random generator.

2019-03-06 Thread aherbert
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 80c94a5916041fef587796abcafe646387c461c0
Author: aherbert 
AuthorDate: Tue Mar 5 12:25:14 2019 +

RNG-79: Modify benchmark to use uniform random generator.
---
 .../rng/examples/jmh/NextDoublePerformance.java| 102 +++--
 1 file changed, 56 insertions(+), 46 deletions(-)

diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoublePerformance.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoublePerformance.java
index f182955..70620f3 100644
--- 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoublePerformance.java
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoublePerformance.java
@@ -41,112 +41,122 @@ import java.util.concurrent.TimeUnit;
 @State(Scope.Benchmark)
 @Fork(value = 1, jvmArgs = { "-server", "-Xms128M", "-Xmx128M" })
 public class NextDoublePerformance {
-// Mimic the generation of the SplitMix64 algorithm
-// and a SplitMix32 algorithm to get a spread of input numbers.
-
-/**
- * The 64-bit golden ratio number.
- */
-private static final long GOLDEN_64 = 0x9e3779b97f4a7c15L;
-/**
- * The 32-bit golden ratio number.
- */
-private static final long GOLDEN_32 = 0x9e3779b9;
-
-/** The long state. */
-private long longState = ThreadLocalRandom.current().nextLong();
-/** The int state. */
-private int intState = ThreadLocalRandom.current().nextInt();
-
 /**
- * Get the next long in the sequence.
+ * Mimic the generation of the SplitMix64 algorithm.
  *
- * @return the long
- */
-private long nextLong() {
-return longState += GOLDEN_64;
-}
-
-/**
- * Get the next int in the sequence.
- *
- * @return the int
+ * The final mixing step must be included otherwise the output numbers 
are sequential
+ * and the test may run with a lack of numbers with higher order bits.
  */
-private int nextInt() {
-return intState += GOLDEN_32;
+@State(Scope.Benchmark)
+public static class LongSource {
+/** The state. */
+private long state = ThreadLocalRandom.current().nextLong();
+
+/**
+ * Get the next long.
+ *
+ * @return the long
+ */
+public final long nextLong() {
+long z = state += 0x9e3779b97f4a7c15L;
+z = (z ^ (z >>> 30)) * 0xbf58476d1ce4e5b9L;
+z = (z ^ (z >>> 27)) * 0x94d049bb133111ebL;
+return z ^ (z >>> 31);
+}
+
+/**
+ * Get the next int.
+ *
+ * Returns the 32 high bits of Stafford variant 4 mix64 function as 
int.
+ *
+ * @return the int
+ */
+public final int nextInt() {
+long z = state += 0x9e3779b97f4a7c15L;
+z = (z ^ (z >>> 33)) * 0x62a9d9ed799705f5L;
+return (int)(((z ^ (z >>> 28)) * 0xcb24d0a5c88c35b3L) >>> 32);
+}
 }
 
 // Benchmark methods
 
 /**
+ * @param source the source
  * @return the long
  */
 @Benchmark
-public long nextDoubleBaseline() {
-return nextLong();
+public long nextDoubleBaseline(LongSource source) {
+return source.nextLong();
 }
 
 /**
+ * @param source the source
  * @return the double
  */
 @Benchmark
-public double nextDoubleUsingBitsToDouble() {
+public double nextDoubleUsingBitsToDouble(LongSource source) {
 // Combine 11 bit unsigned exponent with value 1023 (768 + 255) with 
52 bit mantissa
 // 0x300L = 256 + 512 = 768
 // 0x0ff  = 255
 // This makes a number in the range 1.0 to 2.0 so subtract 1.0
-return Double.longBitsToDouble(0x3ffL << 52 | nextLong() >>> 12) - 1.0;
+return Double.longBitsToDouble(0x3ffL << 52 | source.nextLong() >>> 
12) - 1.0;
 }
 
 /**
+ * @param source the source
  * @return the double
  */
 @Benchmark
-public double nextDoubleUsingMultiply52bits() {
-return (nextLong() >>> 12) * 0x1.0p-52d; // 1.0 / (1L << 52)
+public double nextDoubleUsingMultiply52bits(LongSource source) {
+return (source.nextLong() >>> 12) * 0x1.0p-52d; // 1.0 / (1L << 52)
 }
 
 /**
+ * @param source the source
  * @return the double
  */
 @Benchmark
-public double nextDoubleUsingMultiply53bits() {
-return (nextLong() >>> 11) * 0x1.0p-53d; // 1.0 / (1L << 53)
+public double nextDoubleUsingMultiply53bits(LongSource so

[commons-rng] 08/10: Track changes.

2019-03-06 Thread aherbert
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 bfef2b672a9a21961c75cb024582a2fe5cbb261d
Author: Alex Herbert 
AuthorDate: Wed Mar 6 15:43:35 2019 +

Track changes.
---
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e49e200..0f824fb 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,6 +75,9 @@ re-run tests that fail, and pass the build if they succeed
 within the allotted number of reruns (the test will be marked
 as 'flaky' in the report).
 ">
+  
+Add the methods used from UniformRandomProvider to each sampler in the 
sampling module.
+  
   
 "DiscreteUniformSampler": Algorithms for small and large integer 
ranges have
 been delegated to specialised classes.



[commons-rng] 07/10: Merge branch 'improvement-RNG-73'

2019-03-06 Thread aherbert
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 cf51f2c28a48bdb1d5c4fd98fdd85f63392d8911
Merge: fccc73e fbeeb08
Author: Alex Herbert 
AuthorDate: Wed Mar 6 15:41:19 2019 +

Merge branch 'improvement-RNG-73'

Closes #25

 .../commons/rng/sampling/CollectionSampler.java   |  2 ++
 .../commons/rng/sampling/CombinationSampler.java  |  8 +---
 .../DiscreteProbabilityCollectionSampler.java |  2 ++
 .../org/apache/commons/rng/sampling/ListSampler.java  | 10 +-
 .../commons/rng/sampling/PermutationSampler.java  |  8 ++--
 .../commons/rng/sampling/SubsetSamplerUtils.java  |  6 --
 .../commons/rng/sampling/UnitSphereSampler.java   |  7 +++
 .../distribution/AhrensDieterExponentialSampler.java  |  2 ++
 .../AhrensDieterMarsagliaTsangGammaSampler.java   |  7 +++
 .../distribution/BoxMullerGaussianSampler.java|  2 ++
 .../distribution/BoxMullerLogNormalSampler.java   |  2 ++
 .../BoxMullerNormalizedGaussianSampler.java   |  2 ++
 .../rng/sampling/distribution/ChengBetaSampler.java   |  2 ++
 .../distribution/ContinuousUniformSampler.java|  2 ++
 .../sampling/distribution/DiscreteUniformSampler.java |  4 
 .../rng/sampling/distribution/GeometricSampler.java   | 10 ++
 .../InverseTransformContinuousSampler.java|  4 +++-
 .../distribution/InverseTransformDiscreteSampler.java |  4 +++-
 .../distribution/InverseTransformParetoSampler.java   |  2 ++
 .../distribution/LargeMeanPoissonSampler.java | 11 +--
 .../MarsagliaNormalizedGaussianSampler.java   |  2 ++
 .../rng/sampling/distribution/PoissonSampler.java |  7 +++
 .../sampling/distribution/PoissonSamplerCache.java| 19 +--
 .../distribution/RejectionInversionZipfSampler.java   |  2 ++
 .../distribution/SmallMeanPoissonSampler.java |  8 +---
 .../ZigguratNormalizedGaussianSampler.java| 11 +--
 26 files changed, 119 insertions(+), 27 deletions(-)




[commons-rng] 09/10: Merge branch 'feature-RNG-79'

2019-03-06 Thread aherbert
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 526274452b2ce4a00d8df7ebbe19825709f5bb93
Merge: bfef2b6 80c94a5
Author: Alex Herbert 
AuthorDate: Wed Mar 6 15:44:48 2019 +

Merge branch 'feature-RNG-79'

Closes #28

 commons-rng-core/pom.xml   |   7 +
 .../commons/rng/core/util/NumberFactoryTest.java   | 103 +
 .../rng/examples/jmh/NextDoublePerformance.java| 162 +
 3 files changed, 246 insertions(+), 26 deletions(-)



[commons-rng] 03/10: RNG-79: Updated testFloatGeneration internal order

2019-03-06 Thread aherbert
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 d03726b337653c430789cd18f3d5b9a5d7df21be
Author: Alex Herbert 
AuthorDate: Mon Mar 4 21:48:55 2019 +

RNG-79: Updated testFloatGeneration internal order
---
 .../test/java/org/apache/commons/rng/core/util/NumberFactoryTest.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/commons-rng-core/src/test/java/org/apache/commons/rng/core/util/NumberFactoryTest.java
 
b/commons-rng-core/src/test/java/org/apache/commons/rng/core/util/NumberFactoryTest.java
index 40e2989..5638768 100644
--- 
a/commons-rng-core/src/test/java/org/apache/commons/rng/core/util/NumberFactoryTest.java
+++ 
b/commons-rng-core/src/test/java/org/apache/commons/rng/core/util/NumberFactoryTest.java
@@ -151,8 +151,8 @@ public class NumberFactoryTest {
 Assert.assertEquals(1, Float.intBitsToFloat(0x7f << 23 | allBits >>> 
9) - 1.0f, 1e-6);
 
 final int noBits = 0;
-Assert.assertEquals(0, (noBits >>> 8) * 0x1.0p-24f, 0);
 Assert.assertEquals(0, (noBits >>> 9) * 0x1.0p-23f, 0);
+Assert.assertEquals(0, (noBits >>> 8) * 0x1.0p-24f, 0);
 Assert.assertEquals(0, Float.intBitsToFloat(0x7f << 23 | noBits >>> 9) 
- 1.0f, 0);
 }
 



[commons-rng] 01/10: RNG-73: Add methods used from UniformRandomProvider to the samplers.

2019-03-06 Thread aherbert
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 fbeeb08208c1f92f7ae395451f86a32f54564fe6
Author: Alex Herbert 
AuthorDate: Thu Feb 28 21:15:19 2019 +

RNG-73: Add methods used from UniformRandomProvider to the samplers.
---
 .../commons/rng/sampling/CollectionSampler.java   |  2 ++
 .../commons/rng/sampling/CombinationSampler.java  |  8 +---
 .../DiscreteProbabilityCollectionSampler.java |  2 ++
 .../org/apache/commons/rng/sampling/ListSampler.java  | 10 +-
 .../commons/rng/sampling/PermutationSampler.java  |  8 ++--
 .../commons/rng/sampling/SubsetSamplerUtils.java  |  6 --
 .../commons/rng/sampling/UnitSphereSampler.java   |  7 +++
 .../distribution/AhrensDieterExponentialSampler.java  |  2 ++
 .../AhrensDieterMarsagliaTsangGammaSampler.java   |  7 +++
 .../distribution/BoxMullerGaussianSampler.java|  2 ++
 .../distribution/BoxMullerLogNormalSampler.java   |  2 ++
 .../BoxMullerNormalizedGaussianSampler.java   |  2 ++
 .../rng/sampling/distribution/ChengBetaSampler.java   |  2 ++
 .../distribution/ContinuousUniformSampler.java|  2 ++
 .../sampling/distribution/DiscreteUniformSampler.java |  4 
 .../rng/sampling/distribution/GeometricSampler.java   | 10 ++
 .../InverseTransformContinuousSampler.java|  4 +++-
 .../distribution/InverseTransformDiscreteSampler.java |  4 +++-
 .../distribution/InverseTransformParetoSampler.java   |  2 ++
 .../distribution/LargeMeanPoissonSampler.java | 11 +--
 .../MarsagliaNormalizedGaussianSampler.java   |  2 ++
 .../rng/sampling/distribution/PoissonSampler.java |  7 +++
 .../sampling/distribution/PoissonSamplerCache.java| 19 +--
 .../distribution/RejectionInversionZipfSampler.java   |  2 ++
 .../distribution/SmallMeanPoissonSampler.java |  8 +---
 .../ZigguratNormalizedGaussianSampler.java| 11 +--
 26 files changed, 119 insertions(+), 27 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CollectionSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CollectionSampler.java
index 34c7247..54f9ee9 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CollectionSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CollectionSampler.java
@@ -26,6 +26,8 @@ import org.apache.commons.rng.UniformRandomProvider;
 /**
  * Sampling from a {@link Collection}.
  *
+ * Sampling uses {@link UniformRandomProvider#nextInt(int)}.
+ *
  * @param  Type of items in the collection.
  *
  * @since 1.0
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CombinationSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CombinationSampler.java
index 58d4fe8..eeae0d5 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CombinationSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CombinationSampler.java
@@ -26,14 +26,16 @@ import org.apache.commons.rng.UniformRandomProvider;
  * A combination is a selection of items from a collection, such that 
(unlike
  * permutations) the order of selection does not matter. This
  * sampler can be used to generate a combination in an unspecified order and is
- * faster than the corresponding {@link PermutationSampler}.
+ * faster than the corresponding {@link PermutationSampler}.
  *
  * Note that the sample order is unspecified. For example a sample
  * combination of 2 from 4 may return {@code [0,1]} or {@code [1,0]} as the 
two are
- * equivalent, and the order of a given combination may change in subsequent 
samples.
+ * equivalent, and the order of a given combination may change in subsequent 
samples.
  *
  * The sampler can be used to generate indices to select subsets where the
- * order of the subset is not important.
+ * order of the subset is not important.
+ *
+ * Sampling uses {@link UniformRandomProvider#nextInt(int)}.
  *
  * @see PermutationSampler
  */
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSampler.java
index f85ff14..9bdeaab 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSampler.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteProbabilityCollectionSampler.java
@@ -32,6 +32,8 @@ import org.apache.commons.rng.UniformRandomProvider;
  * Note that if all unique items are assigned the same probability,
  * it is much more efficient to use {@link CollectionSampler}.
  *
+ * Sampling

[commons-rng] 10/10: Track changes.

2019-03-06 Thread aherbert
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 f5ac62537baafcbad749bbda29bd8600ce53c3aa
Author: Alex Herbert 
AuthorDate: Wed Mar 6 15:46:16 2019 +

Track changes.
---
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0f824fb..0e2d57f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,6 +75,9 @@ re-run tests that fail, and pass the build if they succeed
 within the allotted number of reruns (the test will be marked
 as 'flaky' in the report).
 ">
+  
+Benchmark methods for producing nextDouble and nextFloat.
+  
   
 Add the methods used from UniformRandomProvider to each sampler in the 
sampling module.
   



[commons-rng] 02/10: RNG-79: Benchmark methods for producing nextDouble and nextFloat

2019-03-06 Thread aherbert
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 ac929bf427059c957ace0ee880d6b6801d153601
Author: Alex Herbert 
AuthorDate: Mon Mar 4 21:40:17 2019 +

RNG-79: Benchmark methods for producing nextDouble and nextFloat
---
 .../commons/rng/core/util/NumberFactoryTest.java   |  63 +
 .../rng/examples/jmh/NextDoublePerformance.java| 152 +
 2 files changed, 189 insertions(+), 26 deletions(-)

diff --git 
a/commons-rng-core/src/test/java/org/apache/commons/rng/core/util/NumberFactoryTest.java
 
b/commons-rng-core/src/test/java/org/apache/commons/rng/core/util/NumberFactoryTest.java
index 3088ca4..40e2989 100644
--- 
a/commons-rng-core/src/test/java/org/apache/commons/rng/core/util/NumberFactoryTest.java
+++ 
b/commons-rng-core/src/test/java/org/apache/commons/rng/core/util/NumberFactoryTest.java
@@ -29,29 +29,12 @@ public class NumberFactoryTest {
 final int LONG_SIZE = 8;
 
 /** Test values. */
-private static final long[] LONG_TEST_VALUES = new long[] {
-0L,
-1L,
--1L,
-19337L,
-1234567891011213L,
--11109876543211L,
-Long.valueOf(Integer.MAX_VALUE),
-Long.valueOf(Integer.MIN_VALUE),
-Long.MAX_VALUE,
-Long.MIN_VALUE,
-};
+private static final long[] LONG_TEST_VALUES = new long[] { 0L, 1L, -1L, 
19337L, 1234567891011213L,
+-11109876543211L, Long.valueOf(Integer.MAX_VALUE), 
Long.valueOf(Integer.MIN_VALUE), Long.MAX_VALUE,
+Long.MIN_VALUE, };
 /** Test values. */
-private static final int[] INT_TEST_VALUES = new int[] {
-0,
-1,
--1,
-19337,
-1234567891,
--1110987656,
-Integer.MAX_VALUE,
-Integer.MIN_VALUE,
-};
+private static final int[] INT_TEST_VALUES = new int[] { 0, 1, -1, 19337, 
1234567891, -1110987656,
+Integer.MAX_VALUE, Integer.MIN_VALUE, };
 
 @Test
 public void testMakeIntFromLong() {
@@ -85,8 +68,7 @@ public class NumberFactoryTest {
 @Test
 public void testLongArrayFromByteArray2LongArray() {
 final byte[] b = NumberFactory.makeByteArray(LONG_TEST_VALUES);
-Assert.assertArrayEquals(LONG_TEST_VALUES,
- NumberFactory.makeLongArray(b));
+Assert.assertArrayEquals(LONG_TEST_VALUES, 
NumberFactory.makeLongArray(b));
 }
 
 @Test
@@ -100,8 +82,7 @@ public class NumberFactoryTest {
 @Test
 public void testIntArrayFromByteArray2IntArray() {
 final byte[] b = NumberFactory.makeByteArray(INT_TEST_VALUES);
-Assert.assertArrayEquals(INT_TEST_VALUES,
- NumberFactory.makeIntArray(b));
+Assert.assertArrayEquals(INT_TEST_VALUES, 
NumberFactory.makeIntArray(b));
 }
 
 @Test
@@ -159,4 +140,34 @@ public class NumberFactoryTest {
 }
 }
 }
+
+@Test
+public void testFloatGeneration() {
+final int allBits = 0x;
+
+// Not capable of generating 1
+Assert.assertEquals(1, (allBits >>> 9) * 0x1.0p-23f, 1e-6);
+Assert.assertEquals(1, (allBits >>> 8) * 0x1.0p-24f, 1e-6);
+Assert.assertEquals(1, Float.intBitsToFloat(0x7f << 23 | allBits >>> 
9) - 1.0f, 1e-6);
+
+final int noBits = 0;
+Assert.assertEquals(0, (noBits >>> 8) * 0x1.0p-24f, 0);
+Assert.assertEquals(0, (noBits >>> 9) * 0x1.0p-23f, 0);
+Assert.assertEquals(0, Float.intBitsToFloat(0x7f << 23 | noBits >>> 9) 
- 1.0f, 0);
+}
+
+@Test
+public void testDoubleGeneration() {
+final long allBits = 0xL;
+
+// Not capable of generating 1
+Assert.assertEquals(1, (allBits >>> 12) * 0x1.0p-52d, 1e-10);
+Assert.assertEquals(1, (allBits >>> 11) * 0x1.0p-53d, 1e-10);
+Assert.assertEquals(1, Double.longBitsToDouble(0x3ffL << 52 | allBits 
>>> 12) - 1.0, 1e-10);
+
+final long noBits = 0;
+Assert.assertEquals(0, (noBits >>> 12) * 0x1.0p-52d, 0);
+Assert.assertEquals(0, (noBits >>> 11) * 0x1.0p-53d, 0);
+Assert.assertEquals(0, Double.longBitsToDouble(0x3ffL << 52 | noBits 
>>> 12) - 1.0, 0);
+}
 }
diff --git 
a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoublePerformance.java
 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoublePerformance.java
new file mode 100644
index 000..f182955
--- /dev/null
+++ 
b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoublePerformance.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor licen

[commons-rng] branch master updated (fccc73e -> f5ac625)

2019-03-06 Thread aherbert
This is an automated email from the ASF dual-hosted git repository.

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


from fccc73e  InternalUtilsTest: Test for NegativeArraySizeException
 new fbeeb08  RNG-73: Add methods used from UniformRandomProvider to the 
samplers.
 new cf51f2c  Merge branch 'improvement-RNG-73'
 new bfef2b6  Track changes.
 new ac929bf  RNG-79: Benchmark methods for producing nextDouble and 
nextFloat
 new d03726b  RNG-79: Updated testFloatGeneration internal order
 new 5a6c2f5  RNG-79: Updated testFloat/DoubleGeneration delta.
 new d4950ef  RNG-79: NumberFactoryTest floating-point precision uses 
commons-math3
 new 80c94a5  RNG-79: Modify benchmark to use uniform random generator.
 new 5262744  Merge branch 'feature-RNG-79'
 new f5ac625  Track changes.

The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 commons-rng-core/pom.xml   |   7 +
 .../commons/rng/core/util/NumberFactoryTest.java   | 103 +
 .../rng/examples/jmh/NextDoublePerformance.java| 162 +
 .../commons/rng/sampling/CollectionSampler.java|   2 +
 .../commons/rng/sampling/CombinationSampler.java   |   8 +-
 .../DiscreteProbabilityCollectionSampler.java  |   2 +
 .../apache/commons/rng/sampling/ListSampler.java   |  10 +-
 .../commons/rng/sampling/PermutationSampler.java   |   8 +-
 .../commons/rng/sampling/SubsetSamplerUtils.java   |   6 +-
 .../commons/rng/sampling/UnitSphereSampler.java|   7 +
 .../AhrensDieterExponentialSampler.java|   2 +
 .../AhrensDieterMarsagliaTsangGammaSampler.java|   7 +
 .../distribution/BoxMullerGaussianSampler.java |   2 +
 .../distribution/BoxMullerLogNormalSampler.java|   2 +
 .../BoxMullerNormalizedGaussianSampler.java|   2 +
 .../sampling/distribution/ChengBetaSampler.java|   2 +
 .../distribution/ContinuousUniformSampler.java |   2 +
 .../distribution/DiscreteUniformSampler.java   |   4 +
 .../sampling/distribution/GeometricSampler.java|  10 +-
 .../InverseTransformContinuousSampler.java |   4 +-
 .../InverseTransformDiscreteSampler.java   |   4 +-
 .../InverseTransformParetoSampler.java |   2 +
 .../distribution/LargeMeanPoissonSampler.java  |  11 +-
 .../MarsagliaNormalizedGaussianSampler.java|   2 +
 .../rng/sampling/distribution/PoissonSampler.java  |   7 +
 .../sampling/distribution/PoissonSamplerCache.java |  19 ++-
 .../RejectionInversionZipfSampler.java |   2 +
 .../distribution/SmallMeanPoissonSampler.java  |   8 +-
 .../ZigguratNormalizedGaussianSampler.java |  11 +-
 src/changes/changes.xml|   6 +
 30 files changed, 371 insertions(+), 53 deletions(-)
 create mode 100644 
commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoublePerformance.java



  1   2   3   4   5   6   7   8   9   10   >