Beispiel #1
0
/**
 * Description not yet available.
 * \param
 */
double randnegbinomial(double mu,double tau,
  const random_number_generator& rng)
{
  if (tau<=1.0)
  {
    cerr << "Error in randnegbinomial overdispersion must be >=1" << endl;
    ad_exit(1);
  }
  double r=mu/(tau-1);
  double c=r/mu;
  double z=sgamma(r,rng);
  double lambda=z/c;
  return randpoisson(lambda,rng);
}
Beispiel #2
0
double gengam(lua_RNG *o,double a,double r)
/*
**********************************************************************
           GENerates random deviates from GAMma distribution
                              Function
     Generates random deviates from the gamma distribution whose
     density is
          (A**R)/Gamma(R) * X**(R-1) * Exp(-A*X)
                              Arguments
     a --> Location parameter of Gamma distribution
     r --> Shape parameter of Gamma distribution
                              Method
     Renames SGAMMA from TOMS as slightly modified by BWB to use RANF
     instead of SUNIF.
     For details see:
               (Case R >= 1.0)
               Ahrens, J.H. and Dieter, U.
               Generating Gamma Variates by a
               Modified Rejection Technique.
               Comm. ACM, 25,1 (Jan. 1982), 47 - 54.
     Algorithm GD
               (Case 0.0 <= R <= 1.0)
               Ahrens, J.H. and Dieter, U.
               Computer Methods for Sampling from Gamma,
               Beta, Poisson and Binomial Distributions.
               Computing, 12 (1974), 223-246/
     Adapted algorithm GS.
**********************************************************************
*/
{
static double gengam;

    gengam = sgamma(o,r);
    gengam /= a;
    return gengam;
}