ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rannegbn.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include <fvar.hpp>
12 
17 double randnegbinomial(double mu,double tau,
18  const random_number_generator& rng)
19 {
20  if (tau<=1.0)
21  {
22  cerr << "Error in randnegbinomial overdispersion must be >=1" << endl;
23  ad_exit(1);
24  }
25  double r=mu/(tau-1);
26  double c=r/mu;
27  double z=sgamma(r,rng);
28  double lambda=z/c;
29  return randpoisson(lambda,rng);
30 }
exitptr ad_exit
Definition: gradstrc.cpp:53
double randnegbinomial(double mu, double tau, const random_number_generator &rng)
Description not yet available.
Definition: rannegbn.cpp:17
Description not yet available.
Definition: fvar.hpp:7951
prnstream & endl(prnstream &)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
double sgamma(double a, const random_number_generator &_rng)
Description not yet available.
Definition: drangam.cpp:44
double randpoisson(double xm, const random_number_generator &rng)
Poisson random deviates.
Definition: dranpois.cpp:37