List of usage examples for org.apache.commons.rng.sampling.distribution InverseTransformParetoSampler InverseTransformParetoSampler
public InverseTransformParetoSampler(UniformRandomProvider rng, double scale, double shape)
From source file:org.apache.commons.rng.examples.sampling.ProbabilityDensityApproximation.java
/** * Program entry point.// www . j a v a 2 s. c om * * @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"); }