package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
/**
* This class implements random variate generators for
* the Pearson type VI distribution with shape parameters
*
* α1 > 0 and
* α2 > 0, and scale parameter β > 0.
* The density function of this distribution is
*
*
*
* f (x) = (x/β)α1-1/(βB(α1, α2)[1 + x/β]α1+α2) for x > 0,
*
* and f (x) = 0 otherwise,
* where B is the beta function.
*
*/
public class Pearson6Gen extends RandomVariateGen {
protected double alpha1;
protected double alpha2;
protected double beta;
/**
* Creates a Pearson6 random variate generator with parameters
* α1 = alpha1, α2 = alpha2 and β =
* beta, using stream s.
*
*/
public Pearson6Gen (RandomStream s, double alpha1, double alpha2,
double beta) {
super (s, new Pearson6Dist(alpha1, alpha2, beta));
setParams (alpha1, alpha2, beta);
}
/**
* Creates a Pearson6 random variate generator with parameters
*
* α1 = alpha1, α2 = alpha2 and β = 1,
* using stream s.
*
*/
public Pearson6Gen (RandomStream s, double alpha1, double alpha2) {
this (s, alpha1, alpha2, 1.0);
}
/**
* Creates a new generator for the distribution dist,
* using stream s.
*
*/
public Pearson6Gen (RandomStream s, Pearson6Dist dist) {
super (s, dist);
if (dist != null)
setParams(dist.getAlpha1(), dist.getAlpha2(), dist.getBeta());
}
/**
* Generates a variate from the Pearson VI distribution
* with shape parameters
* α1 > 0 and
* α2 > 0, and
* scale parameter β > 0.
*
*/
public static double nextDouble (RandomStream s, double alpha1,
double alpha2, double beta) {
return Pearson6Dist.inverseF (alpha1, alpha2, beta, s.nextDouble());
}
/**
* Returns the α1 parameter of this object.
*
*/
public double getAlpha1() {
return alpha1;
}
/**
* Returns the α2 parameter of this object.
*
*/
public double getAlpha2() {
return alpha2;
}
/**
* Returns the β parameter of this object.
*
*
*/
public double getBeta() {
return beta;
}
/**
* Sets the parameters α1, α2 and β of this object.
*
*/
public void setParams (double alpha1, double alpha2, double beta) {
if (alpha1 <= 0.0)
throw new IllegalArgumentException("alpha1 <= 0");
if (alpha2 <= 0.0)
throw new IllegalArgumentException("alpha2 <= 0");
if (beta <= 0.0)
throw new IllegalArgumentException("beta <= 0");
this.alpha1 = alpha1;
this.alpha2 = alpha2;
this.beta = beta;
}
}
Ads help maintain this website.