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

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

Introduction

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

Prototype

public WeibullDistribution(RandomGenerator rng, double alpha, double beta, double inverseCumAccuracy)
        throws NotStrictlyPositiveException 

Source Link

Document

Creates a Weibull distribution.

Usage

From source file:it.unibo.alchemist.model.implementations.timedistributions.WeibullTime.java

/**
 * @param shapeParameter/*from  w w  w  .jav a  2s .  c  o m*/
 *            shape parameter for this distribution
 * @param scaleParameter
 *            shape parameter for this distribution
 * @param offsetParameter
 *            minimum possible time interval for this distribution
 * @param start
 *            initial time
 * @param random
 *            {@link RandomGenerator} used internally
 */
public WeibullTime(final double shapeParameter, final double scaleParameter, final double offsetParameter,
        final Time start, final RandomGenerator random) {
    this(random, new WeibullDistribution(random, shapeParameter, scaleParameter,
            WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY), offsetParameter, start);
}

From source file:it.unibo.alchemist.model.implementations.timedistributions.WeibullTime.java

/**
 * Generates a {@link WeibullDistribution} given its mean and stdev.
 * //from  w w w  .  ja  v  a 2s.  c  om
 * @param mean
 *            the mean
 * @param deviation
 *            the stdev
 * @param random
 *            the random generator
 * @return a new {@link WeibullDistribution}
 */
protected static WeibullDistribution weibullFromMean(final double mean, final double deviation,
        final RandomGenerator random) {
    final double t = FastMath.log((deviation * deviation) / (mean * mean) + 1);
    double kmin = 0, kmax = 1;
    while (Gamma.logGamma(1 + 2 * kmax) - 2 * Gamma.logGamma(1 + kmax) < t) {
        kmin = kmax;
        kmax *= 2;
    }
    double k = (kmin + kmax) / 2;
    while (kmin < k && k < kmax) {
        if (Gamma.logGamma(1 + 2 * k) - 2 * Gamma.logGamma(1 + k) < t) {
            kmin = k;
        } else {
            kmax = k;
        }
        k = (kmin + kmax) / 2;
    }
    final double shapeParameter = 1 / k;
    final double scaleParameter = mean / FastMath.exp(Gamma.logGamma(1 + k));
    return new WeibullDistribution(random, shapeParameter, scaleParameter,
            WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
}