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


/**
 * This class implements random variate generators for the Nakagami 
 * distribution. See the definition in 
 * {@link umontreal.iro.lecuyer.probdist.NakagamiDist NakagamiDist} of package
 * probdist.
 * 
 */
public class NakagamiGen extends RandomVariateGen  {
   // Distribution parameters
   protected double a;
   protected double lambda;
   protected double c;



   /**
    * Creates a new Nakagami generator with parameters a = a, 
    *  λ = lambda and c = c, using stream s.
    * 
    */
   public NakagamiGen (RandomStream s, double a, double lambda, double c)  {
      super (s, new NakagamiDist (a, lambda, c));
      setParams (a, lambda, c);
   }


   /**
    * Creates a new generator for the distribution dist,
    *      using stream s.
    * 
    */
   public NakagamiGen (RandomStream s, NakagamiDist dist)  {
      super (s, dist);
      if (dist != null)
         setParams (dist.getA(), dist.getLambda(), dist.getC());
   }


   /**
    * Generates a variate from the Nakagami distribution with
    *  parameters a = a, 
    *  λ = lambda and c = c, using stream s.
    * 
    * @param s the random stream
    * 
    *    @param a the location parameter
    * 
    *    @param lambda the scale parameter
    * 
    *    @param c the shape parameter
    * 
    *    @return Generates a variate from the Nakagami distribution
    * 
    */
   public static double nextDouble (RandomStream s, double a, double lambda,
                                    double c) {
      return NakagamiDist.inverseF (a, lambda, c, s.nextDouble());
   }


   /**
    * Returns the location parameter a of this object.
    *   
    * @return the location parameter mu
    * 
    */
   public double getA() {
      return a;
   }


   /**
    * Returns the scale parameter λ of this object.
    *   
    * @return the scale parameter mu
    * 
    */
   public double getLambda() {
      return lambda;
   }


   /**
    * Returns the shape parameter c of this object.
    *   
    * @return the shape parameter mu
    * 
    */
   public double getC() {
      return c;
   }


   protected void setParams (double a, double lambda, double c) {
      if (lambda <= 0.0)
         throw new IllegalArgumentException ("lambda <= 0");
      if (c <= 0.0)
         throw new IllegalArgumentException ("c <= 0");
      this.a = a;
      this.lambda = lambda;
      this.c = c;
   }
}

 

Ads help maintain this website.