package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
/**
* This class implements random variate generators for
* the inverse Gaussian distribution with location parameter
* μ > 0 and scale parameter
* λ > 0.
* The density function of this distribution is
*
*
*
* f (x) = (λ)1/2/(2πx3) e-λ(x-μ)2/(2μ2x) for x > 0.
*
*
*/
public class InverseGaussianGen extends RandomVariateGen {
protected double mu = -1.0;
protected double lambda = -1.0;
/**
* Creates an inverse Gaussian random variate generator
* with parameters μ = mu and λ = lambda,
* using stream s.
*
*/
public InverseGaussianGen (RandomStream s, double mu, double lambda) {
super (s, new InverseGaussianDist(mu, lambda));
setParams (mu, lambda);
}
/**
* Creates a new generator for the distribution dist,
* using stream s.
*
*/
public InverseGaussianGen (RandomStream s, InverseGaussianDist dist) {
super (s, dist);
if (dist != null)
setParams (dist.getMu(), dist.getLambda());
}
/**
* Generates a variate from the inverse gaussian distribution
* with location parameter μ > 0 and scale parameter
* λ > 0.
*
*/
public static double nextDouble (RandomStream s,
double mu, double lambda) {
return InverseGaussianDist.inverseF (mu, lambda, s.nextDouble());
}
/**
* Returns the parameter μ of this object.
*
*/
public double getMu() {
return mu;
}
/**
* Returns the parameter λ of this object.
*
*
*/
public double getLambda() {
return lambda;
}
/**
* Sets the parameters μ and λ of this object.
*
*/
protected void setParams (double mu, double lambda) {
if (lambda <= 0.0)
throw new IllegalArgumentException ("lambda <= 0");
if (mu <= 0.0)
throw new IllegalArgumentException ("mu <= 0");
this.mu = mu;
this.lambda = lambda;
}
}
Ads help maintain this website.