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; } }

Ads help maintain this website.