All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cloudbus.cloudsim.distributions.NormalDistr Maven / Gradle / Ivy

Go to download

CloudSim Plus: A modern, highly extensible and easier-to-use Java 8 Framework for Modeling and Simulation of Cloud Computing Infrastructures and Services

There is a newer version: 8.0.0
Show newest version
package org.cloudbus.cloudsim.distributions;

import org.apache.commons.math3.distribution.NormalDistribution;
import org.apache.commons.math3.random.JDKRandomGenerator;
import org.apache.commons.math3.random.RandomGenerator;

/**
 * A Pseudo-Random Number Generator following the
 * Normal (Gaussian) distribution.
 *
 * @author Manoel Campos da Silva Filho
 */
public class NormalDistr extends NormalDistribution implements ContinuousDistribution{
    private long seed;

    /**
     * Creates a Normal (Gaussian) Pseudo-Random Number Generator (RNG) using the current time as seed.
     *
     * 

Internally, it relies on the {@link JDKRandomGenerator}, * a wrapper for the {@link java.util.Random} class * that doesn't have high-quality randomness properties * but is very fast.

* * @param mean the mean for the distribution. * @param standardDeviation the standard deviation for the distribution. * * @see #NormalDistr(double, double, long, RandomGenerator) */ public NormalDistr(final double mean, final double standardDeviation) { this(mean, standardDeviation, ContinuousDistribution.defaultSeed()); } /** * Creates a Normal (Gaussian) Pseudo-Random Number Generator (RNG). * *

Internally, it relies on the {@link JDKRandomGenerator}, * a wrapper for the {@link java.util.Random} class * that doesn't have high-quality randomness properties * but is very fast.

* * @param mean the mean for the distribution. * @param standardDeviation the standard deviation for the distribution. * @param seed the seed to be used. * * @see #NormalDistr(double, double, long, RandomGenerator) */ public NormalDistr(final double mean, final double standardDeviation, final long seed) { this(mean, standardDeviation, seed, ContinuousDistribution.newDefaultGen(seed)); } /** * Creates a Normal (Gaussian) Pseudo-Random Number Generator (RNG). * @param mean the mean for the distribution. * @param standardDeviation the standard deviation for the distribution. * @param seed the seed already used to initialize the Pseudo-Random Number Generator * @param rng the actual Pseudo-Random Number Generator that will be the base * to generate random numbers following a continuous distribution. */ public NormalDistr(final double mean, final double standardDeviation, final long seed, final RandomGenerator rng) { super(rng, mean, standardDeviation); if(seed < 0){ throw new IllegalArgumentException("Seed cannot be negative"); } this.seed = seed; } @Override public long getSeed() { return seed; } @Override public void reseedRandomGenerator(final long seed) { super.reseedRandomGenerator(seed); this.seed = seed; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy