Code example for Random

Methods: nextGaussian

0
    /** 
     * @see edu.virginia.cs.geneticalgorithm.gene.Gene#mutate(java.util.Random) 
     */ 
    @Override 
    public Gene mutate(final Random rng) {
        final double rawGaussian = rng.nextGaussian();
        final double newVal = _value + rawGaussian * _sigma;
        return new IntervalGene(newVal, _sigma);
    } 
 
    /** 
     * @param rng Random number generator used to perform the next mutation 
     * @param sigma Standard deviation to use when mutating the {@link Gene} 
     * @return Mutated gene 
     * @see edu.virginia.cs.geneticalgorithm.gene.Gene#mutate(java.util.Random) 
     */ 
    public Gene mutate(final Random rng, final double sigma) {
        final double rawGaussian = rng.nextGaussian();
        final double newVal = _value + rawGaussian * sigma;
        return new IntervalGene(newVal, sigma);