Example usage for org.apache.commons.math3.distribution NormalDistribution NormalDistribution

List of usage examples for org.apache.commons.math3.distribution NormalDistribution NormalDistribution

Introduction

In this page you can find the example usage for org.apache.commons.math3.distribution NormalDistribution NormalDistribution.

Prototype

public NormalDistribution(RandomGenerator rng, double mean, double sd, double inverseCumAccuracy)
        throws NotStrictlyPositiveException 

Source Link

Document

Creates a normal distribution.

Usage

From source file:com.anhth12.distributions.Distributions.java

public static RealDistribution normal(RandomGenerator rng, double std) {
    if (normalDistributions.get(rng, std) == null) {
        RealDistribution ret = new NormalDistribution(rng, 0, std,
                NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
        normalDistributions.put(rng, std, ret);
        return ret;
    }/*from w  w  w .j  ava  2 s . c  o m*/
    return normalDistributions.get(rng, std);
}

From source file:com.anhth12.nn.conf.NeuralNetworkConfiguration.java

public NeuralNetworkConfiguration(NeuralNetworkConfiguration conf) {
    this.layerFactory = conf.layerFactory;
    this.batchSize = conf.batchSize;
    this.sparsity = conf.sparsity;
    this.useAdaGrad = conf.useAdaGrad;
    this.lr = conf.lr;
    this.momentum = conf.momentum;
    this.l2 = conf.l2;
    this.numIterations = conf.numIterations;
    this.k = conf.k;
    this.corruptionLevel = conf.corruptionLevel;
    this.visibleUnit = conf.visibleUnit;
    this.hiddenUnit = conf.hiddenUnit;
    this.useRegularization = conf.useRegularization;
    this.momentumAfter = conf.momentumAfter;
    this.resetAdaGradIterations = conf.resetAdaGradIterations;
    this.dropOut = conf.dropOut;
    //        this.applySparsity = conf.applySparsity;
    this.weightInit = conf.weightInit;
    this.optimizationAlgo = conf.optimizationAlgo;
    this.lossFunction = conf.lossFunction;
    //        this.renderWeightsEveryNumEpochs = neuralNetConfiguration.renderWeightsEveryNumEpochs;
    this.concateBias = conf.concateBias;
    this.constrainGradientToUnitNorm = conf.constrainGradientToUnitNorm;
    this.rng = conf.rng;
    this.dist = conf.dist;
    //        this.seed = conf.seed;
    this.nIn = conf.nIn;
    this.nOut = conf.nOut;
    this.activationFunction = conf.activationFunction;
    this.visibleUnit = conf.visibleUnit;
    //        this.weightShape = neuralNetConfiguration.weightShape;
    //        this.stride = neuralNetConfiguration.stride;
    //        this.numFeatureMaps = neuralNetConfiguration.numFeatureMaps;
    //        this.filterSize = neuralNetConfiguration.filterSize;
    //        this.featureMapSize = neuralNetConfiguration.featureMapSize;
    if (dist == null) {
        this.dist = new NormalDistribution(rng, 0, .01, NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
    }//from  w  w w.  j  ava 2 s .  c  o m

    this.hiddenUnit = conf.hiddenUnit;
}

From source file:org.apache.mahout.clustering.dirichlet.UncommonDistributions.java

/**
 * Return a random value from a normal distribution with the given mean and standard deviation
 * //from  w ww  . j ava2s .  c  om
 * @param mean
 *          a double mean value
 * @param sd
 *          a double standard deviation
 * @return a double sample
 */
public static double rNorm(double mean, double sd) {
    RealDistribution dist = new NormalDistribution(RANDOM.getRandomGenerator(), mean, sd,
            NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
    return dist.sample();
}

From source file:org.apache.mahout.math.random.NormalTest.java

@Test
public void testSample() throws Exception {
    double[] data = new double[10001];
    Sampler<Double> sampler = new Normal();
    for (int i = 0; i < data.length; i++) {
        data[i] = sampler.sample();// ww w.  j av  a2s .  c  o m
    }
    Arrays.sort(data);

    NormalDistribution reference = new NormalDistribution(RandomUtils.getRandom().getRandomGenerator(), 0, 1,
            NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
    assertEquals("Median", reference.inverseCumulativeProbability(0.5), data[5000], 0.04);
}

From source file:org.asoem.greyfish.utils.math.RandomGenerators.java

/**
 * Generates a random value for the normal distribution with the mean equal to {@code mu} and standard deviation
 * equal to {@code sigma}./*w w w.j a v a  2s.c  o  m*/
 *
 * @param mu    the mean of the distribution
 * @param sigma the standard deviation of the distribution
 * @return a random value for the given normal distribution
 */
public static double nextNormal(final RandomGenerator rng, final double mu, final double sigma) {
    final NormalDistribution normalDistribution = new NormalDistribution(rng, mu, sigma,
            NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
    while (true) {
        final double sample = normalDistribution.sample();
        if (!Doubles.isFinite(sample)) {
            logger.warn("Discarding non finite sample from normal distribution (mu={}, sigma={}): {}", mu,
                    sigma, sample);
            continue;
        }
        return sample;
    }
}

From source file:org.briljantframework.data.dataframe.transform.TransformationTests.java

@Before
public void setUp() throws Exception {
    NormalDistribution distribution = new NormalDistribution(new Well1024a(100), 10, 2,
            NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
    train = getBuilder().set("a", Vector.fromSupplier(distribution::sample, 100))
            .set("b", Vector.fromSupplier(distribution::sample, 100))
            .set("c", Vector.fromSupplier(distribution::sample, 100)).build();

    test = getBuilder().set("a", Vector.fromSupplier(distribution::sample, 100))
            .set("c", Vector.fromSupplier(distribution::sample, 100))
            .set("b", Vector.fromSupplier(distribution::sample, 80)).build();

}

From source file:org.nmdp.ngs.tools.GenerateBed.java

/**
 * Main.//from w  ww  .  j  a  v a  2  s .com
 *
 * @param args command line arguments
 */
public static void main(final String[] args) {
    Switch about = new Switch("a", "about", "display about message");
    Switch help = new Switch("h", "help", "display help message");
    FileArgument bedFile = new FileArgument("o", "bed-file", "output BED file, default stdout", false);
    IntegerArgument n = new IntegerArgument("n", "n", "number of BED records to generate, default " + DEFAULT_N,
            false);
    IntegerArgument size = new IntegerArgument("s", "size", "chromosome size, default " + DEFAULT_SIZE, false);
    StringArgument chrom = new StringArgument("c", "chrom", "chromosome name, default " + DEFAULT_CHROM, false);
    DoubleArgument meanLength = new DoubleArgument("l", "mean-length",
            "mean length, default " + DEFAULT_MEAN_LENGTH, false);
    DoubleArgument lengthVariation = new DoubleArgument("v", "length-variation",
            "length variation, default " + DEFAULT_LENGTH_VARIATION, false);
    IntegerArgument seed = new IntegerArgument("z", "seed",
            "random number seed, default relates to current time", false);

    ArgumentList arguments = new ArgumentList(about, help, bedFile, n, size, chrom, meanLength, lengthVariation,
            seed);
    CommandLine commandLine = new CommandLine(args);

    GenerateBed generateBed = null;
    try {
        CommandLineParser.parse(commandLine, arguments);
        if (about.wasFound()) {
            About.about(System.out);
            System.exit(0);
        }
        if (help.wasFound()) {
            Usage.usage(USAGE, null, commandLine, arguments, System.out);
            System.exit(0);
        }

        RandomGenerator random = seed.wasFound() ? new MersenneTwister(seed.getValue()) : new MersenneTwister();
        double lv = Math.max(NO_VARIATION, lengthVariation.getValue(DEFAULT_LENGTH_VARIATION));
        RealDistribution length = new NormalDistribution(random, meanLength.getValue(DEFAULT_MEAN_LENGTH), lv,
                NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);

        generateBed = new GenerateBed(bedFile.getValue(), n.getValue(DEFAULT_N), size.getValue(DEFAULT_SIZE),
                chrom.getValue(DEFAULT_CHROM), random, length);
    } catch (CommandLineParseException e) {
        Usage.usage(USAGE, e, commandLine, arguments, System.err);
        System.exit(-1);
    }
    try {
        System.exit(generateBed.call());
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:org.nmdp.ngs.tools.GeneratePairedEndReads.java

/**
 * Main./*from   w w w .  ja v  a2 s .  c  o m*/
 *
 * @param args command line arguments
 */
public static void main(final String[] args) {
    Switch about = new Switch("a", "about", "display about message");
    Switch help = new Switch("h", "help", "display help message");
    FileArgument referenceFile = new FileArgument("r", "reference",
            "reference input file, in fasta format, default stdin", false);
    FileArgument firstReadFile = new FileArgument("1", "first-read", "first read output file, in fastq format",
            true);
    FileArgument secondReadFile = new FileArgument("2", "second-read",
            "second read output file, in fastq format", true);
    DoubleArgument meanLength = new DoubleArgument("l", "mean-length",
            "mean length, default " + DEFAULT_MEAN_LENGTH, false);
    DoubleArgument lengthVariation = new DoubleArgument("v", "length-variation",
            "length variation, default " + DEFAULT_LENGTH_VARIATION, false);
    DoubleArgument meanInsertSize = new DoubleArgument("j", "mean-insert-size",
            "mean insert size, default " + DEFAULT_MEAN_INSERT_SIZE, false);
    DoubleArgument insertSizeVariation = new DoubleArgument("k", "insert-size-variation",
            "insert size variation, default " + DEFAULT_INSERT_SIZE_VARIATION, false);
    IntegerArgument minimumCoverage = new IntegerArgument("c", "minimum-coverage",
            "minimum coverage, default " + DEFAULT_MINIMUM_COVERAGE, false);
    IntegerArgument meanCoverage = new IntegerArgument("g", "mean-coverage", "mean coverage", false);
    StringArgument qualityType = new StringArgument("u", "quality",
            "quality strategy type { illumina, normal }, default normal", false);
    DoubleArgument meanQualityWeight = new DoubleArgument("w", "mean-quality-weight",
            "mean quality weight, default " + DEFAULT_MEAN_QUALITY_WEIGHT, false);
    DoubleArgument qualityWeightVariation = new DoubleArgument("t", "quality-weight-variation",
            "quality weight variation, default " + DEFAULT_QUALITY_WEIGHT_VARIATION, false);
    DoubleArgument meanQuality = new DoubleArgument("q", "mean-quality",
            "mean quality, default " + DEFAULT_MEAN_QUALITY, false);
    DoubleArgument qualityVariation = new DoubleArgument("f", "quality-variation",
            "quality variation, default " + DEFAULT_QUALITY_VARIATION, false);
    StringArgument mutationType = new StringArgument("m", "mutation",
            "mutation strategy type { substitution, insertion, deletion, ambiguous, indel, composite }, default identity",
            false);
    DoubleArgument extendInsertionRate = new DoubleArgument("x", "extend-insertion-rate",
            "extend insertion rate, default " + DEFAULT_EXTEND_INSERTION_RATE, false);
    IntegerArgument maximumInsertionLength = new IntegerArgument("e", "maximum-insertion-length",
            "maximum insertion length, default " + DEFAULT_MAXIMUM_INSERTION_LENGTH, false);
    DoubleArgument insertionRate = new DoubleArgument("i", "insertion-rate",
            "insertion rate, default " + DEFAULT_INSERTION_RATE, false);
    DoubleArgument deletionRate = new DoubleArgument("d", "deletion-rate",
            "deletion rate, default " + DEFAULT_DELETION_RATE, false);
    DoubleArgument substitutionRate = new DoubleArgument("s", "substitution-rate",
            "substitution rate, default " + DEFAULT_SUBSTITUTION_RATE, false);
    DoubleArgument indelRate = new DoubleArgument("y", "indel-rate",
            "indel rate, default " + DEFAULT_INDEL_RATE, false);
    DoubleArgument ambiguousRate = new DoubleArgument("b", "ambiguous-rate",
            "ambiguous substitution rate, default " + DEFAULT_AMBIGUOUS_RATE, false);
    DoubleArgument mutationRate = new DoubleArgument("n", "mutation-rate",
            "mutation rate, default " + DEFAULT_MUTATION_RATE, false);
    IntegerArgument seed = new IntegerArgument("z", "seed",
            "random number seed, default relates to current time", false);

    ArgumentList arguments = new ArgumentList(about, help, referenceFile, firstReadFile, secondReadFile,
            meanLength, lengthVariation, meanInsertSize, insertSizeVariation, minimumCoverage, meanCoverage,
            qualityType, meanQualityWeight, qualityWeightVariation, meanQuality, qualityVariation, mutationType,
            extendInsertionRate, maximumInsertionLength, insertionRate, deletionRate, substitutionRate,
            indelRate, ambiguousRate, mutationRate, seed);

    CommandLine commandLine = new CommandLine(args);

    GeneratePairedEndReads generatePairedEndReads = null;
    try {
        CommandLineParser.parse(commandLine, arguments);
        if (about.wasFound()) {
            About.about(System.out);
            System.exit(0);
        }
        if (help.wasFound()) {
            Usage.usage(USAGE, null, commandLine, arguments, System.out);
            System.exit(0);
        }

        RandomGenerator random = seed.wasFound() ? new MersenneTwister(seed.getValue()) : new MersenneTwister();

        double lv = Math.max(NO_VARIATION, lengthVariation.getValue(DEFAULT_LENGTH_VARIATION));
        RealDistribution length = new NormalDistribution(random, meanLength.getValue(DEFAULT_MEAN_LENGTH), lv,
                NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);

        double isv = Math.max(NO_VARIATION, insertSizeVariation.getValue(DEFAULT_INSERT_SIZE_VARIATION));
        RealDistribution insertSize = new NormalDistribution(random,
                meanInsertSize.getValue(DEFAULT_MEAN_INSERT_SIZE), isv,
                NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);

        CoverageStrategy coverage = DEFAULT_COVERAGE;
        if (minimumCoverage.wasFound()) {
            coverage = new MinimumCoverageStrategy(minimumCoverage.getValue());
        } else if (meanCoverage.wasFound()) {
            coverage = new MeanCoverageStrategy(meanCoverage.getValue());
        }

        QualityStrategy quality = null;
        if ("illumina".equals(qualityType.getValue())) {
            RealDistribution realDistribution = new NormalDistribution(random,
                    meanQualityWeight.getValue(DEFAULT_MEAN_QUALITY_WEIGHT),
                    qualityWeightVariation.getValue(DEFAULT_QUALITY_WEIGHT_VARIATION),
                    NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
            quality = new ScoreFunctionQualityStrategy(realDistribution, ScoreFunctions.illumina());
        } else {
            RealDistribution realDistribution = new NormalDistribution(random,
                    meanQuality.getValue(DEFAULT_MEAN_QUALITY),
                    qualityVariation.getValue(DEFAULT_QUALITY_VARIATION),
                    NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
            quality = new RealDistributionQualityStrategy(realDistribution);
        }

        MutationStrategy mutation = DEFAULT_MUTATION;
        if (mutationType.wasFound()) {
            if ("substitution".equals(mutationType.getValue())) {
                mutation = new SubstitutionMutationStrategy(random);
            } else if ("ambiguous".equals(mutationType.getValue())) {
                mutation = new AmbiguousSubstitutionMutationStrategy();
            } else if ("insertion".equals(mutationType.getValue())) {
                mutation = new InsertionMutationStrategy(random,
                        extendInsertionRate.getValue(DEFAULT_EXTEND_INSERTION_RATE),
                        maximumInsertionLength.getValue(DEFAULT_MAXIMUM_INSERTION_LENGTH));
            } else if ("deletion".equals(mutationType.getValue())) {
                mutation = new DeletionMutationStrategy();
            } else if ("indel".equals(mutationType.getValue())) {
                InsertionMutationStrategy insertion = new InsertionMutationStrategy(random,
                        insertionRate.getValue(DEFAULT_INSERTION_RATE),
                        maximumInsertionLength.getValue(DEFAULT_MAXIMUM_INSERTION_LENGTH));
                DeletionMutationStrategy deletion = new DeletionMutationStrategy();
                mutation = new IndelMutationStrategy(random, insertion,
                        insertionRate.getValue(DEFAULT_INSERTION_RATE), deletion,
                        deletionRate.getValue(DEFAULT_DELETION_RATE));
            } else if ("composite".equals(mutationType.getValue())) {
                SubstitutionMutationStrategy substitution = new SubstitutionMutationStrategy(random);
                InsertionMutationStrategy insertion = new InsertionMutationStrategy(random,
                        insertionRate.getValue(DEFAULT_INSERTION_RATE),
                        maximumInsertionLength.getValue(DEFAULT_MAXIMUM_INSERTION_LENGTH));
                DeletionMutationStrategy deletion = new DeletionMutationStrategy();
                IndelMutationStrategy indel = new IndelMutationStrategy(random, insertion,
                        insertionRate.getValue(DEFAULT_INSERTION_RATE), deletion,
                        deletionRate.getValue(DEFAULT_DELETION_RATE));
                AmbiguousSubstitutionMutationStrategy ambiguous = new AmbiguousSubstitutionMutationStrategy();
                mutation = new CompositeMutationStrategy(random, substitution,
                        substitutionRate.getValue(DEFAULT_SUBSTITUTION_RATE), indel,
                        indelRate.getValue(DEFAULT_INDEL_RATE), ambiguous,
                        ambiguousRate.getValue(DEFAULT_AMBIGUOUS_RATE));
            }
        }

        generatePairedEndReads = new GeneratePairedEndReads(referenceFile.getValue(), firstReadFile.getValue(),
                secondReadFile.getValue(), random, length, insertSize, quality, coverage,
                mutationRate.getValue(DEFAULT_MUTATION_RATE), mutation);
    } catch (CommandLineParseException e) {
        if (about.wasFound()) {
            About.about(System.out);
            System.exit(0);
        }
        if (help.wasFound()) {
            Usage.usage(USAGE, null, commandLine, arguments, System.out);
            System.exit(0);
        }
        Usage.usage(USAGE, e, commandLine, arguments, System.err);
        System.exit(-1);
    }
    try {
        System.exit(generatePairedEndReads.call());
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:org.nmdp.ngs.tools.GenerateReads.java

/**
 * Main.//from w w w  . j a v  a 2  s.  c  om
 *
 * @param args command line arguments
 */
public static void main(final String[] args) {
    Switch about = new Switch("a", "about", "display about message");
    Switch help = new Switch("h", "help", "display help message");
    FileArgument referenceFile = new FileArgument("r", "reference",
            "reference input file, in fasta format, default stdin", false);
    FileArgument readFile = new FileArgument("o", "read", "read output file, in fastq format, default stdout",
            false);

    DoubleArgument meanLength = new DoubleArgument("l", "mean-length",
            "mean length, default " + DEFAULT_MEAN_LENGTH, false);
    DoubleArgument lengthVariation = new DoubleArgument("v", "length-variation",
            "length variation, default " + DEFAULT_LENGTH_VARIATION, false);
    IntegerArgument minimumCoverage = new IntegerArgument("c", "minimum-coverage",
            "minimum coverage, default " + DEFAULT_MINIMUM_COVERAGE, false);
    IntegerArgument meanCoverage = new IntegerArgument("g", "mean-coverage", "mean coverage", false);
    StringArgument qualityType = new StringArgument("u", "quality",
            "quality strategy type { illumina, normal }, default normal", false);
    DoubleArgument meanQualityWeight = new DoubleArgument("w", "mean-quality-weight",
            "mean quality weight, default " + DEFAULT_MEAN_QUALITY_WEIGHT, false);
    DoubleArgument qualityWeightVariation = new DoubleArgument("t", "quality-weight-variation",
            "quality weight variation, default " + DEFAULT_QUALITY_WEIGHT_VARIATION, false);
    DoubleArgument meanQuality = new DoubleArgument("q", "mean-quality",
            "mean quality, default " + DEFAULT_MEAN_QUALITY, false);
    DoubleArgument qualityVariation = new DoubleArgument("f", "quality-variation",
            "quality variation, default " + DEFAULT_QUALITY_VARIATION, false);
    StringArgument mutationType = new StringArgument("m", "mutation",
            "mutation strategy type { substitution, insertion, deletion, ambiguous, indel, composite }, default identity",
            false);
    DoubleArgument extendInsertionRate = new DoubleArgument("x", "extend-insertion-rate",
            "extend insertion rate, default " + DEFAULT_EXTEND_INSERTION_RATE, false);
    IntegerArgument maximumInsertionLength = new IntegerArgument("e", "maximum-insertion-length",
            "maximum insertion length, default " + DEFAULT_MAXIMUM_INSERTION_LENGTH, false);
    DoubleArgument insertionRate = new DoubleArgument("i", "insertion-rate",
            "insertion rate, default " + DEFAULT_INSERTION_RATE, false);
    DoubleArgument deletionRate = new DoubleArgument("d", "deletion-rate",
            "deletion rate, default " + DEFAULT_DELETION_RATE, false);
    DoubleArgument substitutionRate = new DoubleArgument("s", "substitution-rate",
            "substitution rate, default " + DEFAULT_SUBSTITUTION_RATE, false);
    DoubleArgument indelRate = new DoubleArgument("y", "indel-rate",
            "indel rate, default " + DEFAULT_INDEL_RATE, false);
    DoubleArgument ambiguousRate = new DoubleArgument("b", "ambiguous-rate",
            "ambiguous substitution rate, default " + DEFAULT_AMBIGUOUS_RATE, false);
    DoubleArgument mutationRate = new DoubleArgument("n", "mutation-rate",
            "mutation rate, default " + DEFAULT_MUTATION_RATE, false);
    IntegerArgument seed = new IntegerArgument("z", "seed",
            "random number seed, default relates to current time", false);

    ArgumentList arguments = new ArgumentList(about, help, referenceFile, readFile, meanLength, lengthVariation,
            minimumCoverage, meanCoverage, qualityType, meanQualityWeight, qualityWeightVariation, meanQuality,
            qualityVariation, mutationType, extendInsertionRate, maximumInsertionLength, insertionRate,
            deletionRate, substitutionRate, indelRate, ambiguousRate, mutationRate, seed);

    CommandLine commandLine = new CommandLine(args);

    GenerateReads generateReads = null;
    try {
        CommandLineParser.parse(commandLine, arguments);
        if (about.wasFound()) {
            About.about(System.out);
            System.exit(0);
        }
        if (help.wasFound()) {
            Usage.usage(USAGE, null, commandLine, arguments, System.out);
            System.exit(0);
        }

        RandomGenerator random = seed.wasFound() ? new MersenneTwister(seed.getValue()) : new MersenneTwister();

        double lv = Math.max(NO_VARIATION, lengthVariation.getValue(DEFAULT_LENGTH_VARIATION));
        RealDistribution length = new NormalDistribution(random, meanLength.getValue(DEFAULT_MEAN_LENGTH), lv,
                NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);

        CoverageStrategy coverage = DEFAULT_COVERAGE;
        if (minimumCoverage.wasFound()) {
            coverage = new MinimumCoverageStrategy(minimumCoverage.getValue());
        } else if (meanCoverage.wasFound()) {
            coverage = new MeanCoverageStrategy(meanCoverage.getValue());
        }

        QualityStrategy quality = null;
        if ("illumina".equals(qualityType.getValue())) {
            RealDistribution realDistribution = new NormalDistribution(random,
                    meanQualityWeight.getValue(DEFAULT_MEAN_QUALITY_WEIGHT),
                    qualityWeightVariation.getValue(DEFAULT_QUALITY_WEIGHT_VARIATION),
                    NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
            quality = new ScoreFunctionQualityStrategy(realDistribution, ScoreFunctions.illumina());
        } else {
            RealDistribution realDistribution = new NormalDistribution(random,
                    meanQuality.getValue(DEFAULT_MEAN_QUALITY),
                    qualityVariation.getValue(DEFAULT_QUALITY_VARIATION),
                    NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
            quality = new RealDistributionQualityStrategy(realDistribution);
        }

        MutationStrategy mutation = DEFAULT_MUTATION;
        if (mutationType.wasFound()) {
            if ("substitution".equals(mutationType.getValue())) {
                mutation = new SubstitutionMutationStrategy(random);
            } else if ("ambiguous".equals(mutationType.getValue())) {
                mutation = new AmbiguousSubstitutionMutationStrategy();
            } else if ("insertion".equals(mutationType.getValue())) {
                mutation = new InsertionMutationStrategy(random,
                        extendInsertionRate.getValue(DEFAULT_EXTEND_INSERTION_RATE),
                        maximumInsertionLength.getValue(DEFAULT_MAXIMUM_INSERTION_LENGTH));
            } else if ("deletion".equals(mutationType.getValue())) {
                mutation = new DeletionMutationStrategy();
            } else if ("indel".equals(mutationType.getValue())) {
                InsertionMutationStrategy insertion = new InsertionMutationStrategy(random,
                        insertionRate.getValue(DEFAULT_INSERTION_RATE),
                        maximumInsertionLength.getValue(DEFAULT_MAXIMUM_INSERTION_LENGTH));
                DeletionMutationStrategy deletion = new DeletionMutationStrategy();
                mutation = new IndelMutationStrategy(random, insertion,
                        insertionRate.getValue(DEFAULT_INSERTION_RATE), deletion,
                        deletionRate.getValue(DEFAULT_DELETION_RATE));
            } else if ("composite".equals(mutationType.getValue())) {
                SubstitutionMutationStrategy substitution = new SubstitutionMutationStrategy(random);
                InsertionMutationStrategy insertion = new InsertionMutationStrategy(random,
                        insertionRate.getValue(DEFAULT_INSERTION_RATE),
                        maximumInsertionLength.getValue(DEFAULT_MAXIMUM_INSERTION_LENGTH));
                DeletionMutationStrategy deletion = new DeletionMutationStrategy();
                IndelMutationStrategy indel = new IndelMutationStrategy(random, insertion,
                        insertionRate.getValue(DEFAULT_INSERTION_RATE), deletion,
                        deletionRate.getValue(DEFAULT_DELETION_RATE));
                AmbiguousSubstitutionMutationStrategy ambiguous = new AmbiguousSubstitutionMutationStrategy();
                mutation = new CompositeMutationStrategy(random, substitution,
                        substitutionRate.getValue(DEFAULT_SUBSTITUTION_RATE), indel,
                        indelRate.getValue(DEFAULT_INDEL_RATE), ambiguous,
                        ambiguousRate.getValue(DEFAULT_AMBIGUOUS_RATE));
            }
        }

        generateReads = new GenerateReads(referenceFile.getValue(), readFile.getValue(), random, length,
                quality, coverage, mutationRate.getValue(DEFAULT_MUTATION_RATE), mutation);
    } catch (CommandLineParseException e) {
        if (about.wasFound()) {
            About.about(System.out);
            System.exit(0);
        }
        if (help.wasFound()) {
            Usage.usage(USAGE, null, commandLine, arguments, System.out);
            System.exit(0);
        }
        Usage.usage(USAGE, e, commandLine, arguments, System.err);
        System.exit(-1);
    }
    try {
        System.exit(generateReads.call());
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:tools.descartes.dlim.generator.util.FunctionValueCalculator.java

/**
 * Create a new FunctionValueCalculator.
 *
 * @param rndGenerator//  w w w . j  a  v a  2 s  .  c  o m
 *            The random number generator for Noises.
 * @param noiseMode
 *            Set this to IGeneratorConstants.CALIBRATION if Noises are to
 *            return 0.
 */
public FunctionValueCalculator(JDKRandomGenerator rndGenerator, String noiseMode) {
    this.rndGenerator = rndGenerator;
    nDistribution = new NormalDistribution(rndGenerator, 0, 1,
            NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
    this.noiseMode = noiseMode;
}