ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
rannegbn.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <fvar.hpp>
00012 
00017 double randnegbinomial(double mu,double tau,
00018   const random_number_generator& rng)
00019 {
00020   if (tau<=1.0)
00021   {
00022     cerr << "Error in randnegbinomial overdispersion must be >=1" << endl;
00023     ad_exit(1);
00024   }
00025   double r=mu/(tau-1);
00026   double c=r/mu;
00027   double z=sgamma(r,rng);
00028   double lambda=z/c;
00029   return randpoisson(lambda,rng);
00030 }