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


/**
 * This class implements methods for generating random variates from the
 * Fréchet distribution, with location parameter δ, scale
 *  parameter β > 0, and shape parameter 
 * α > 0, where we use
 *  the notation 
 * z = (x - δ)/β. It has density
 * 

*

*
* f (x) = αe-z-α/(βzα+1),        for x > δ *

* The density is 0 for * x <= δ. * */ public class FrechetGen extends RandomVariateGen { private double delta; private double beta; private double alpha; /** * Creates a Fréchet random number generator with α = * alpha, β = 1 and * δ = 0 using stream s. * */ public FrechetGen (RandomStream s, double alpha) { this (s, alpha, 1.0, 0.0); } /** * Creates a Fréchet random number generator with parameters * α = alpha, β = beta and δ = delta using stream s. * */ public FrechetGen (RandomStream s, double alpha, double beta, double delta) { super (s, new FrechetDist (alpha, beta, delta)); setParams (alpha, beta, delta); } /** * Creates a new generator for the Fréchet distribution dist * and stream s. * */ public FrechetGen (RandomStream s, FrechetDist dist) { super (s, dist); if (dist != null) setParams (dist.getAlpha(), dist.getBeta(), dist.getDelta()); } /** * Generates a new variate from the Fréchet distribution with parameters * α = alpha, β = beta and δ = delta using stream s. * */ public static double nextDouble (RandomStream s, double alpha, double beta, double delta) { return FrechetDist.inverseF (alpha, beta, delta, s.nextDouble()); } /** * Returns the parameter α. * */ public double getAlpha() { return alpha; } /** * Returns the parameter β. * */ public double getBeta() { return beta; } /** * Returns the parameter δ. * * */ public double getDelta() { return delta; } /** * Sets the parameters α, β and δ of this object. * */ protected void setParams (double alpha, double beta, double delta) { if (beta <= 0.0) throw new IllegalArgumentException ("beta <= 0"); if (alpha <= 0.0) throw new IllegalArgumentException ("alpha <= 0"); this.delta = delta; this.beta = beta; this.alpha = alpha; } }

Ads help maintain this website.