Example usage for org.apache.commons.rng.simple RandomSource XOR_SHIFT_1024_S

List of usage examples for org.apache.commons.rng.simple RandomSource XOR_SHIFT_1024_S

Introduction

In this page you can find the example usage for org.apache.commons.rng.simple RandomSource XOR_SHIFT_1024_S.

Prototype

RandomSource XOR_SHIFT_1024_S

To view the source code for org.apache.commons.rng.simple RandomSource XOR_SHIFT_1024_S.

Click Source Link

Document

Source of randomness is org.apache.commons.rng.core.source64.XorShift1024Star .

Usage

From source file:org.apache.commons.rng.examples.sampling.ProbabilityDensityApproximation.java

/**
 * Program entry point./*from   w ww.j a  v  a  2 s . c o  m*/
 *
 * @param args Argument. They must be provided, in the following order:
 * <ol>
 *  <li>Number of "equal-width" bins.</li>
 *  <li>Number of samples.</li>
 * </ol>
 * @throws IOException if failure occurred while writing to files.
 */
public static void main(String[] args) throws IOException {
    final int numBins = Integer.valueOf(args[0]);
    final long numSamples = Long.valueOf(args[1]);
    final ProbabilityDensityApproximation app = new ProbabilityDensityApproximation(numBins, numSamples);

    final UniformRandomProvider rng = RandomSource.create(RandomSource.XOR_SHIFT_1024_S);

    final double gaussMean = 1;
    final double gaussSigma = 2;
    final double gaussMin = -9;
    final double gaussMax = 11;
    app.createDensity(new GaussianSampler(new ZigguratNormalizedGaussianSampler(rng), gaussMean, gaussSigma),
            gaussMin, gaussMax, "gauss.ziggurat.txt");
    app.createDensity(new GaussianSampler(new MarsagliaNormalizedGaussianSampler(rng), gaussMean, gaussSigma),
            gaussMin, gaussMax, "gauss.marsaglia.txt");
    app.createDensity(new GaussianSampler(new BoxMullerNormalizedGaussianSampler(rng), gaussMean, gaussSigma),
            gaussMin, gaussMax, "gauss.boxmuller.txt");

    final double alphaBeta = 4.3;
    final double betaBeta = 2.1;
    final double betaMin = 0;
    final double betaMax = 1;
    app.createDensity(new ChengBetaSampler(rng, alphaBeta, betaBeta), betaMin, betaMax, "beta.case1.txt");
    final double alphaBetaAlt = 0.5678;
    final double betaBetaAlt = 0.1234;
    app.createDensity(new ChengBetaSampler(rng, alphaBetaAlt, betaBetaAlt), betaMin, betaMax, "beta.case2.txt");

    final double meanExp = 3.45;
    final double expMin = 0;
    final double expMax = 60;
    app.createDensity(new AhrensDieterExponentialSampler(rng, meanExp), expMin, expMax, "exp.txt");

    final double thetaGammaSmallerThanOne = 0.1234;
    final double alphaGamma = 3.456;
    final double gammaMin = 0;
    final double gammaMax1 = 40;
    app.createDensity(new AhrensDieterMarsagliaTsangGammaSampler(rng, alphaGamma, thetaGammaSmallerThanOne),
            gammaMin, gammaMax1, "gamma.case1.txt");
    final double thetaGammaLargerThanOne = 2.345;
    final double gammaMax2 = 70;
    app.createDensity(new AhrensDieterMarsagliaTsangGammaSampler(rng, alphaGamma, thetaGammaLargerThanOne),
            gammaMin, gammaMax2, "gamma.case2.txt");

    final double scalePareto = 23.45;
    final double shapePareto = 0.789;
    final double paretoMin = 23;
    final double paretoMax = 400;
    app.createDensity(new InverseTransformParetoSampler(rng, scalePareto, shapePareto), paretoMin, paretoMax,
            "pareto.txt");

    final double loUniform = -9.876;
    final double hiUniform = 5.432;
    app.createDensity(new ContinuousUniformSampler(rng, loUniform, hiUniform), loUniform, hiUniform,
            "uniform.txt");

    final double scaleLogNormal = 2.345;
    final double shapeLogNormal = 0.1234;
    final double logNormalMin = 5;
    final double logNormalMax = 25;
    app.createDensity(
            new LogNormalSampler(new ZigguratNormalizedGaussianSampler(rng), scaleLogNormal, shapeLogNormal),
            logNormalMin, logNormalMax, "lognormal.ziggurat.txt");
    app.createDensity(
            new LogNormalSampler(new MarsagliaNormalizedGaussianSampler(rng), scaleLogNormal, shapeLogNormal),
            logNormalMin, logNormalMax, "lognormal.marsaglia.txt");
    app.createDensity(
            new LogNormalSampler(new BoxMullerNormalizedGaussianSampler(rng), scaleLogNormal, shapeLogNormal),
            logNormalMin, logNormalMax, "lognormal.boxmuller.txt");
}

From source file:org.apache.commons.rng.examples.stress.GeneratorsList.java

/**
 * Creates list.//  ww  w.  j a va2 s  . c  om
 */
public GeneratorsList() {
    list.add(RandomSource.create(RandomSource.JDK));
    list.add(RandomSource.create(RandomSource.MT));
    list.add(RandomSource.create(RandomSource.WELL_512_A));
    list.add(RandomSource.create(RandomSource.WELL_1024_A));
    list.add(RandomSource.create(RandomSource.WELL_19937_A));
    list.add(RandomSource.create(RandomSource.WELL_19937_C));
    list.add(RandomSource.create(RandomSource.WELL_44497_A));
    list.add(RandomSource.create(RandomSource.WELL_44497_B));
    list.add(RandomSource.create(RandomSource.ISAAC));
    list.add(RandomSource.create(RandomSource.MT_64));
    list.add(RandomSource.create(RandomSource.SPLIT_MIX_64));
    list.add(RandomSource.create(RandomSource.XOR_SHIFT_1024_S));
    list.add(RandomSource.create(RandomSource.TWO_CMRES));
    list.add(RandomSource.create(RandomSource.MWC_256));
    list.add(RandomSource.create(RandomSource.KISS));
}