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


/**
 * This class implements random variate generators for 
 * the normal inverse gaussian (NIG) distribution. See the definition of
 * {@link umontreal.iro.lecuyer.probdist.NormalInverseGaussianDist NormalInverseGaussianDist}
 * 
 */
public class NormalInverseGaussianGen extends RandomVariateGen  {
   protected double mu;
   protected double delta = -1.0;
   protected double alpha = -1.0;
   protected double beta = -2.0;
   protected double gamma = -1.0;



   /**
    * Creates an normal inverse gaussian random variate generator with parameters
    *  α = alpha, β = beta,  μ = mu
    *  and  δ = delta, using stream s.
    * 
    */
   public NormalInverseGaussianGen (RandomStream s, double alpha,
                                    double beta, double mu, double delta)  {
      super (s, new NormalInverseGaussianDist(alpha, beta, mu, delta));
      setParams (alpha, beta, mu, delta);
   }


   /**
    * Creates a new generator for the distribution dist,
    *      using stream s.
    * 
    */
   public NormalInverseGaussianGen (RandomStream s,
                                    NormalInverseGaussianDist dist)  {
      super (s, dist);
      if (dist != null)
         setParams (dist.getAlpha(), dist.getBeta(), dist.getMu(),
                    dist.getDelta());
   }


   /**
    * NOT IMPLEMENTED. Use the daughter classes.
    * 
    */
   public static double nextDouble (RandomStream s, double alpha,
                                    double beta, double mu, double delta) {
      return NormalInverseGaussianDist.inverseF (alpha, beta, mu, delta,
                                                 s.nextDouble());
   }


   /**
    * Returns the parameter α of this object.
    * 
    */
   public double getAlpha() {
      return alpha;
   }


   /**
    * Returns the parameter β of this object.
    * 
    */
   public double getBeta() {
      return beta;
   }


   /**
    * Returns the parameter μ of this object.
    * 
    */
   public double getMu() {
      return mu;
   }


   /**
    * Returns the parameter δ of this object.
    * 
    */
   public double getDelta() {
      return delta;
   }


   /**
    * Sets the parameters  α,  β, μ and δ of this object.
    * 
    */
   public void setParams (double alpha, double beta, double mu,
                          double delta) {
      if (delta <= 0.0)
         throw new IllegalArgumentException ("delta <= 0");
      if (alpha <= 0.0)
         throw new IllegalArgumentException ("alpha <= 0");
      if (Math.abs(beta) >= alpha)
         throw new IllegalArgumentException ("|beta| >= alpha");

      gamma = Math.sqrt(alpha*alpha - beta*beta);

      this.mu = mu;
      this.delta = delta;
      this.beta = beta;
      this.alpha = alpha;
   }
 
}


 

Ads help maintain this website.