You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2022/03/02 13:44:11 UTC

[commons-rng] branch master updated (88608c2 -> de8c604)

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 88608c2  RNG-167: Sampling from a t-distribution
     new af2e589  Add TSampler to example sampling application
     new 7019a2f  Add example histogram of the TSampler output to the userguide.
     new de8c604  Add TSampler to continuous sampler performance JMH example

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:
 .../distribution/ContinuousSamplersPerformance.java      |   6 +++++-
 .../sampling/ProbabilityDensityApproximationCommand.java |  14 +++++++++++++-
 .../resources/checkstyle/checkstyle-suppressions.xml     |   1 +
 src/site/apt/userguide/dist_density_approx.apt           |   2 ++
 .../resources/images/userguide/dist_density_approx/t.png | Bin 0 -> 6727 bytes
 5 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 src/site/resources/images/userguide/dist_density_approx/t.png

[commons-rng] 01/03: Add TSampler to example sampling application

Posted by ah...@apache.org.
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 af2e5892c6169b541c7125e8d5707af93ea1b276
Author: aherbert <ah...@apache.org>
AuthorDate: Wed Mar 2 13:22:13 2022 +0000

    Add TSampler to example sampling application
---
 .../sampling/ProbabilityDensityApproximationCommand.java   | 14 +++++++++++++-
 src/main/resources/checkstyle/checkstyle-suppressions.xml  |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/ProbabilityDensityApproximationCommand.java b/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/ProbabilityDensityApproximationCommand.java
index 541d397..04d3105 100644
--- a/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/ProbabilityDensityApproximationCommand.java
+++ b/commons-rng-examples/examples-sampling/src/main/java/org/apache/commons/rng/examples/sampling/ProbabilityDensityApproximationCommand.java
@@ -32,6 +32,7 @@ import org.apache.commons.rng.sampling.distribution.ZigguratNormalizedGaussianSa
 import org.apache.commons.rng.sampling.distribution.ZigguratSampler;
 import org.apache.commons.rng.sampling.distribution.MarsagliaNormalizedGaussianSampler;
 import org.apache.commons.rng.sampling.distribution.StableSampler;
+import org.apache.commons.rng.sampling.distribution.TSampler;
 import org.apache.commons.rng.sampling.distribution.BoxMullerNormalizedGaussianSampler;
 import org.apache.commons.rng.sampling.distribution.ChengBetaSampler;
 import org.apache.commons.rng.sampling.distribution.AhrensDieterExponentialSampler;
@@ -48,7 +49,7 @@ import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
  */
 @Command(name = "density",
          description = {"Approximate the probability density of samplers."})
-class ProbabilityDensityApproximationCommand  implements Callable<Void> {
+class ProbabilityDensityApproximationCommand implements Callable<Void> {
     /** The standard options. */
     @Mixin
     private StandardOptions reusableOptions;
@@ -120,6 +121,8 @@ class ProbabilityDensityApproximationCommand  implements Callable<Void> {
         LevySampler,
         /** The stable sampler. */
         StableSampler,
+        /** The t sampler. */
+        TSampler,
     }
 
     /**
@@ -327,6 +330,15 @@ class ProbabilityDensityApproximationCommand  implements Callable<Void> {
                           stableMin, stableMax, "stable");
         }
 
+        if (samplers.contains(Sampler.TSampler)) {
+            final double tDegreesOfFreedom = 1.23;
+            // Quantiles 0.02 to 0.98 (avoid long tail to infinity)
+            final double tMin = -9.9264;
+            final double tMax = 9.9264;
+            createDensity(TSampler.of(rng, tDegreesOfFreedom),
+                          tMin, tMax, "t");
+        }
+
         return null;
     }
 }
diff --git a/src/main/resources/checkstyle/checkstyle-suppressions.xml b/src/main/resources/checkstyle/checkstyle-suppressions.xml
index 6c54013..8305dfe 100644
--- a/src/main/resources/checkstyle/checkstyle-suppressions.xml
+++ b/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -32,6 +32,7 @@
   <suppress checks="LineLength" files=".*[/\\]test[/\\].*" />
   <suppress checks="IllegalCatch" files=".*[/\\]test[/\\].*" />
   <suppress checks="MethodLength" files="(MersenneTwister64|Well44497[ab]|MultiplyWithCarry256)Test" />
+  <suppress checks="MethodLength" files="ProbabilityDensityApproximationCommand" />
   <suppress checks="FileLength" files="[\\/]StableSamplerTest" />
   <suppress checks="FileLength" files="[\\/]ZigguratSamplerPerformance" />
 </suppressions>

[commons-rng] 03/03: Add TSampler to continuous sampler performance JMH example

Posted by ah...@apache.org.
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 de8c604c59fff097a1e14a9b925e30bf63ec81fb
Author: aherbert <ah...@apache.org>
AuthorDate: Wed Mar 2 13:41:27 2022 +0000

    Add TSampler to continuous sampler performance JMH example
---
 .../jmh/sampling/distribution/ContinuousSamplersPerformance.java    | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ContinuousSamplersPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ContinuousSamplersPerformance.java
index b619a15..4af303e 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ContinuousSamplersPerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ContinuousSamplersPerformance.java
@@ -30,6 +30,7 @@ import org.apache.commons.rng.sampling.distribution.LevySampler;
 import org.apache.commons.rng.sampling.distribution.LogNormalSampler;
 import org.apache.commons.rng.sampling.distribution.MarsagliaNormalizedGaussianSampler;
 import org.apache.commons.rng.sampling.distribution.StableSampler;
+import org.apache.commons.rng.sampling.distribution.TSampler;
 import org.apache.commons.rng.sampling.distribution.ZigguratSampler;
 import org.apache.commons.rng.sampling.distribution.ZigguratNormalizedGaussianSampler;
 
@@ -91,7 +92,8 @@ public class ContinuousSamplersPerformance {
                 "ChengBetaSampler",
                 "ContinuousUniformSampler",
                 "InverseTransformParetoSampler",
-                "StableSampler"})
+                "StableSampler",
+                "TSampler"})
         private String samplerType;
 
         /** The sampler. */
@@ -146,6 +148,8 @@ public class ContinuousSamplersPerformance {
                 sampler = InverseTransformParetoSampler.of(rng, 23.45, 0.1234);
             } else if ("StableSampler".equals(samplerType)) {
                 sampler = StableSampler.of(rng, 1.3, 0.2);
+            } else if ("TSampler".equals(samplerType)) {
+                sampler = TSampler.of(rng, 1.23);
             }
         }
     }

[commons-rng] 02/03: Add example histogram of the TSampler output to the userguide.

Posted by ah...@apache.org.
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 7019a2f07f0d96a906e08b6035e244184ace1530
Author: aherbert <ah...@apache.org>
AuthorDate: Wed Mar 2 13:26:34 2022 +0000

    Add example histogram of the TSampler output to the userguide.
---
 src/site/apt/userguide/dist_density_approx.apt           |   2 ++
 .../resources/images/userguide/dist_density_approx/t.png | Bin 0 -> 6727 bytes
 2 files changed, 2 insertions(+)

diff --git a/src/site/apt/userguide/dist_density_approx.apt b/src/site/apt/userguide/dist_density_approx.apt
index 2201763..c8fc32f 100644
--- a/src/site/apt/userguide/dist_density_approx.apt
+++ b/src/site/apt/userguide/dist_density_approx.apt
@@ -43,3 +43,5 @@
 [../images/userguide/dist_density_approx/levy.png]
 
 [../images/userguide/dist_density_approx/stable.png]
+
+[../images/userguide/dist_density_approx/t.png]
diff --git a/src/site/resources/images/userguide/dist_density_approx/t.png b/src/site/resources/images/userguide/dist_density_approx/t.png
new file mode 100644
index 0000000..9089b9d
Binary files /dev/null and b/src/site/resources/images/userguide/dist_density_approx/t.png differ