commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [06/50] commons-rng git commit: RNG-30: Unit tests for continuous distributions.
Date Mon, 21 Nov 2016 17:03:56 GMT
RNG-30: Unit tests for continuous distributions.


Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/76e17009
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/76e17009
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/76e17009

Branch: refs/heads/master
Commit: 76e17009a48665993d3b2952b436370716c88795
Parents: 3ece8fd
Author: Gilles <erans@apache.org>
Authored: Sat Nov 12 16:36:23 2016 +0100
Committer: Gilles <erans@apache.org>
Committed: Sat Nov 12 16:36:23 2016 +0100

----------------------------------------------------------------------
 .../distribution/ContinuousSamplersList.java    | 123 +++++++++++++++++++
 1 file changed, 123 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/76e17009/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ContinuousSamplersList.java
----------------------------------------------------------------------
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 f310775..b660738 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
@@ -46,6 +46,129 @@ public class ContinuousSamplersList {
             add(LIST, new org.apache.commons.math3.distribution.NormalDistribution(meanNormal,
sigmaNormal),
                 new BoxMullerGaussianSampler(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(alphaBeta,
betaBeta),
+                RandomSource.create(RandomSource.ISAAC));
+            // Beta ("Cheng").
+            add(LIST, new org.apache.commons.math3.distribution.BetaDistribution(alphaBeta,
betaBeta),
+                new ChengBetaSampler(RandomSource.create(RandomSource.MWC_256), alphaBeta,
betaBeta));
+
+            // Cauchy ("inverse method").
+            final double medianCauchy = 0.123;
+            final double scaleCauchy = 4.5;
+            add(LIST, new org.apache.commons.math3.distribution.CauchyDistribution(medianCauchy,
scaleCauchy),
+                RandomSource.create(RandomSource.WELL_19937_C));
+
+            // Chi-square ("inverse method").
+            final int dofChi2 = 12;
+            add(LIST, new org.apache.commons.math3.distribution.ChiSquaredDistribution(dofChi2),
+                RandomSource.create(RandomSource.WELL_19937_A));
+
+            // Exponential ("inverse method").
+            final double meanExp = 3.45;
+            add(LIST, new org.apache.commons.math3.distribution.ExponentialDistribution(meanExp),
+                RandomSource.create(RandomSource.WELL_44497_A));
+            // Exponential.
+            add(LIST, new org.apache.commons.math3.distribution.ExponentialDistribution(meanExp),
+                new AhrensDieterExponentialSampler(RandomSource.create(RandomSource.MT),
meanExp));
+
+            // F ("inverse method").
+            final int numDofF = 4;
+            final int denomDofF = 7;
+            add(LIST, new org.apache.commons.math3.distribution.FDistribution(numDofF, denomDofF),
+                RandomSource.create(RandomSource.MT_64));
+
+            // Gamma ("inverse method").
+            final double thetaGammaSmallerThanOne = 0.1234;
+            final double thetaGammaLargerThanOne = 2.345;
+            final double alphaGamma = 3.456;
+            add(LIST, new org.apache.commons.math3.distribution.GammaDistribution(thetaGammaLargerThanOne,
alphaGamma),
+                RandomSource.create(RandomSource.SPLIT_MIX_64));
+            // Gamma (theta < 1).
+            add(LIST, new org.apache.commons.math3.distribution.GammaDistribution(thetaGammaSmallerThanOne,
alphaGamma),
+                new AhrensDieterMarsagliaTsangGammaSampler(RandomSource.create(RandomSource.XOR_SHIFT_1024_S),
+                                                           alphaGamma, thetaGammaSmallerThanOne));
+            // Gamma (theta > 1).
+            add(LIST, new org.apache.commons.math3.distribution.GammaDistribution(thetaGammaLargerThanOne,
alphaGamma),
+                new AhrensDieterMarsagliaTsangGammaSampler(RandomSource.create(RandomSource.WELL_44497_B),
+                                                           alphaGamma, thetaGammaLargerThanOne));
+
+            // Gumbel ("inverse method").
+            final double muGumbel = -4.56;
+            final double betaGumbel = 0.123;
+            add(LIST, new org.apache.commons.math3.distribution.GumbelDistribution(muGumbel,
betaGumbel),
+                RandomSource.create(RandomSource.WELL_1024_A));
+
+            // Laplace ("inverse method").
+            final double muLaplace = 12.3;
+            final double betaLaplace = 5.6;
+            add(LIST, new org.apache.commons.math3.distribution.LaplaceDistribution(muLaplace,
betaLaplace),
+                RandomSource.create(RandomSource.WELL_1024_A));
+
+            // Levy ("inverse method").
+            final double muLevy = -1.098;
+            final double cLevy = 0.76;
+            add(LIST, new org.apache.commons.math3.distribution.LevyDistribution(muLevy,
cLevy),
+                RandomSource.create(RandomSource.TWO_CMRES));
+
+            // Log normal ("inverse method").
+            final double scaleLogNormal = 23.45;
+            final double shapeLogNormal = 0.1234;
+            add(LIST, new org.apache.commons.math3.distribution.LogNormalDistribution(scaleLogNormal,
shapeLogNormal),
+                RandomSource.create(RandomSource.KISS));
+            // Log normal ("Box-Muller").
+            add(LIST, new org.apache.commons.math3.distribution.LogNormalDistribution(scaleLogNormal,
shapeLogNormal),
+                new BoxMullerLogNormalSampler(RandomSource.create(RandomSource.XOR_SHIFT_1024_S),
scaleLogNormal, shapeLogNormal));
+
+            // Logistic ("inverse method").
+            final double muLogistic = -123.456;
+            final double sLogistic = 7.89;
+            add(LIST, new org.apache.commons.math3.distribution.LogisticDistribution(muLogistic,
sLogistic),
+                RandomSource.create(RandomSource.TWO_CMRES_SELECT, null, 2, 6));
+
+            // Nakagami ("inverse method").
+            final double muNakagami = 78.9;
+            final double omegaNakagami = 23.4;
+            add(LIST, new org.apache.commons.math3.distribution.NakagamiDistribution(muNakagami,
omegaNakagami),
+                RandomSource.create(RandomSource.TWO_CMRES_SELECT, null, 5, 3));
+
+            // Pareto ("inverse method").
+            final double scalePareto = 23.45;
+            final double shapePareto = 0.1234;
+            add(LIST, new org.apache.commons.math3.distribution.ParetoDistribution(scalePareto,
shapePareto),
+                RandomSource.create(RandomSource.TWO_CMRES_SELECT, null, 9, 11));
+            // Pareto.
+            add(LIST, new org.apache.commons.math3.distribution.ParetoDistribution(scalePareto,
shapePareto),
+                new InverseMethodParetoSampler(RandomSource.create(RandomSource.XOR_SHIFT_1024_S),
scalePareto, shapePareto));
+
+            // T ("inverse method").
+            final double dofT = 0.76543;
+            add(LIST, new org.apache.commons.math3.distribution.TDistribution(dofT),
+                RandomSource.create(RandomSource.ISAAC));
+
+            // Triangular ("inverse method").
+            final double aTriangle = -0.76543;
+            final double cTriangle = -0.65432;
+            final double bTriangle = -0.54321;
+            add(LIST, new org.apache.commons.math3.distribution.TriangularDistribution(aTriangle,
cTriangle, bTriangle),
+                RandomSource.create(RandomSource.MT));
+
+            // Uniform ("inverse method").
+            final double loUniform = -1.098;
+            final double hiUniform = 0.76;
+            add(LIST, new org.apache.commons.math3.distribution.UniformRealDistribution(loUniform,
hiUniform),
+                RandomSource.create(RandomSource.TWO_CMRES));
+            // Uniform.
+            add(LIST, new org.apache.commons.math3.distribution.UniformRealDistribution(loUniform,
hiUniform),
+                new ContinuousUniformSampler(RandomSource.create(RandomSource.MT_64), loUniform,
hiUniform));
+
+            // Weibull
+            final double alphaWeibull = 678.9;
+            final double betaWeibull = 98.76;
+            add(LIST, new org.apache.commons.math3.distribution.WeibullDistribution(alphaWeibull,
betaWeibull),
+                RandomSource.create(RandomSource.WELL_44497_B));
         } catch (Exception e) {
             System.err.println("Unexpected exception while creating the list of samplers:
" + e);
             e.printStackTrace(System.err);


Mime
View raw message