package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
/**
* This class implements random variate generators for the
* noncentral chi square distribution with ν degrees of freedom
* and noncentrality parameter λ. See the definition in
* {@link umontreal.iro.lecuyer.probdist.ChiSquareNoncentralDist ChiSquareNoncentralDist}.
*
*/
public class ChiSquareNoncentralGen extends RandomVariateGen {
protected double nu = -1.0;
protected double lambda = -1.0;
/**
* Creates a noncentral chi square random variate generator
* with ν > 0 degrees of freedom and noncentrality parameter λ > 0,
* using stream s.
*
*/
public ChiSquareNoncentralGen (RandomStream s, double nu, double lambda) {
super (s, new ChiSquareNoncentralDist(nu, lambda));
setParams (nu, lambda);
}
/**
* Create a new generator for the distribution dist
* and stream s.
*
*/
public ChiSquareNoncentralGen (RandomStream s,
ChiSquareNoncentralDist dist) {
super (s, dist);
if (dist != null)
setParams (dist.getNu (), dist.getLambda());
}
/**
* Generates a new variate from the noncentral chi square
* distribution with ν degrees of freedom and noncentrality parameter λ,
* using stream s.
*
*/
public static double nextDouble (RandomStream s,
double nu, double lambda) {
return ChiSquareNoncentralDist.inverseF (nu, lambda, s.nextDouble());
}
/**
* Returns the value of ν of this object.
*
*/
public double getNu() {
return nu;
}
/**
* Returns the value of λ for this object.
*
*
*/
public double getLambda() {
return lambda;
}
/**
* Sets the parameters ν = nu and λ =
* lambda of this object.
*
*/
protected void setParams (double nu, double lambda) {
if (nu <= 0.0)
throw new IllegalArgumentException ("nu <= 0");
if (lambda < 0.0)
throw new IllegalArgumentException ("lambda < 0");
this.nu = nu;
this.lambda = lambda;
}
}
Ads help maintain this website.