package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
/**
* This class implements random variate generators for one of the Pareto
* distributions, with parameters α > 0 and β > 0.
* Its density function is
*
*
*
* f (x) = αβα / xα+1 for x > β, 0 otherwise.
*
* The (non-static) nextDouble method simply calls inverseF on the
* distribution.
*
*/
public class ParetoGen extends RandomVariateGen {
protected double alpha;
protected double beta;
/**
* Creates a Pareto random variate generator with parameters α =
* alpha and β = beta, using stream s.
*
*/
public ParetoGen (RandomStream s, double alpha, double beta) {
super (s, new ParetoDist(alpha, beta));
setParams(alpha, beta);
}
/**
* Creates a Pareto random variate generator with parameters α =
* alpha and β = 1, using stream s.
*
*/
public ParetoGen (RandomStream s, double alpha) {
this (s, alpha, 1.0);
}
/**
* Creates a new generator for the Pareto distribution
* dist and stream s.
*
*/
public ParetoGen (RandomStream s, ParetoDist dist) {
super (s, dist);
if (dist != null)
setParams(dist.getAlpha(), dist.getBeta());
}
/**
* Generates a new variate from the Pareto distribution
* with parameters α = alpha and β = beta,
* using stream s.
*
*/
public static double nextDouble (RandomStream s,
double alpha, double beta) {
return ParetoDist.inverseF (alpha, beta, s.nextDouble());
}
/**
* Returns the parameter α of this object.
*
*/
public double getAlpha() {
return alpha;
}
/**
* Returns the parameter β of this object.
*
*/
public double getBeta() {
return beta;
}
protected void setParams (double alpha, double beta) {
if (alpha <= 0.0)
throw new IllegalArgumentException ("alpha <= 0");
if (beta <= 0.0)
throw new IllegalArgumentException ("beta <= 0");
this.alpha = alpha;
this.beta = beta;
}
}
Ads help maintain this website.