package umontreal.iro.lecuyer.probdist;


/**
 * Extends the {@link GammaDist} distribution with constructors accepting the
 * mean μ and variance σ2 as arguments instead of a shape parameter
 * α and a scale parameter λ.
 * Since 
 * μ = α/λ, and 
 * σ2 = α/λ2,
 * the shape and scale parameters are 
 * α = μ2/σ2, and
 * 
 * λ = μ/σ2, respectively.
 * 
 */
public class GammaDistFromMoments extends GammaDist {



   /**
    * Constructs a gamma distribution with mean mean,
    *  variance var, and d decimal of precision.
    * 
    * @param mean the desired mean.
    * 
    *    @param var the desired variance.
    * 
    *    @param d the number of decimals of precision.
    * 
    * 
    */
   public GammaDistFromMoments (double mean, double var, int d) {
      super (mean * mean / var, mean / var, d);
   }


   /**
    * Constructs a gamma distribution with
    *  mean mean, and variance var.
    * 
    * @param mean the desired mean.
    * 
    *    @param var the desired variance.
    * 
    */
   public GammaDistFromMoments (double mean, double var) {
      super (mean * mean / var, mean / var);
   }
}

 

Ads help maintain this website.