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

umontreal.iro.lecuyer.randvar.WeibullGen Maven / Gradle / Ivy

Go to download

SSJ is a Java library for stochastic simulation, developed under the direction of Pierre L'Ecuyer, in the Département d'Informatique et de Recherche Opérationnelle (DIRO), at the Université de Montréal. It provides facilities for generating uniform and nonuniform random variates, computing different measures related to probability distributions, performing goodness-of-fit tests, applying quasi-Monte Carlo methods, collecting (elementary) statistics, and programming discrete-event simulations with both events and processes.

The newest version!


/*
 * Class:        WeibullGen
 * Description:  Weibull random number generator
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Université de Montréal
 * Organization: DIRO, Université de Montréal
 * @author       
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   GPL licence site.
 */

package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;


/**
 * This class implements random variate generators for the 
 * Weibull distribution. Its density is
 * 
 * 

*
* f (x) = αλα(x - δ)α-1exp[- (λ(x - δ))α]         for x > δ, *

* and f (x) = 0 elsewhere, where * α > 0, and * λ > 0. * *

* The (non-static) nextDouble method simply calls inverseF on the * distribution. * */ public class WeibullGen extends RandomVariateGen { private double alpha = -1.0; private double lambda = -1.0; private double delta = -1.0; /** * Creates a Weibull random variate generator with parameters * α = alpha, λ = lambda and δ = * delta, using stream s. * */ public WeibullGen (RandomStream s, double alpha, double lambda, double delta) { super (s, new WeibullDist(alpha, lambda, delta)); setParams (alpha, lambda, delta); } /** * Creates a Weibull random variate generator with parameters * α = alpha, * λ = 1 and * δ = 0, using stream * s. * */ public WeibullGen (RandomStream s, double alpha) { this (s, alpha, 1.0, 0.0); } /** * Creates a new generator for the Weibull distribution dist * and stream s. * */ public WeibullGen (RandomStream s, WeibullDist dist) { super (s, dist); if (dist != null) setParams (dist.getAlpha(), dist.getLambda(), dist.getDelta()); } /** * Uses inversion to generate a new variate from the Weibull * distribution with parameters α = alpha, * λ = lambda, and δ = delta, using * stream s. * */ public static double nextDouble (RandomStream s, double alpha, double lambda, double delta) { return WeibullDist.inverseF (alpha, lambda, delta, s.nextDouble()); } /** * Returns the parameter α. * */ public double getAlpha() { return alpha; } /** * Returns the parameter λ. * */ public double getLambda() { return lambda; } /** * Returns the parameter δ. * * */ public double getDelta() { return delta; } /** * Sets the parameters α, λ and δ for this * object. * */ public void setParams (double alpha, double lambda, double delta) { if (alpha <= 0.0) throw new IllegalArgumentException ("alpha <= 0"); if (lambda <= 0.0) throw new IllegalArgumentException ("lambda <= 0"); this.alpha = alpha; this.lambda = lambda; this.delta = delta; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy