ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dpois.cpp
Go to the documentation of this file.
1 #include "statsLib.h"
2 
35 dvariable dpois(const double& k, const prevariable& lambda)
36 {
38  dvariable tmp = -k*log(lambda)+lambda + gammln(k+1.);
40  return tmp;
41 }
42 
51 dvariable dpois(const prevariable& k, const prevariable& lambda)
52 {
54  dvariable tmp = -k*log(lambda)+lambda + gammln(k+1.);
56  return tmp;
57 }
58 
67 dvariable dpois(const dvector& k, const dvar_vector& lambda)
68 {
70  int i;
71  int n = size_count(k);
72  dvariable nll=0;
73  for(i = 1; i <= n; i++)
74  {
75  // nll -= k(i)*log(lambda(i))+lambda(i)+gammln(k(i)+1.);
76  nll += -k(i)*log(lambda(i))+lambda(i)+gammln(k(i)+1.);
77  }
79  return nll;
80 }
81 
82 
Base class for dvariable.
Definition: fvar.hpp:1315
double gammln(double xx)
Log gamma function.
Definition: combc.cpp:52
void RETURN_ARRAYS_DECREMENT(void)
Decrements gradient_structure::RETURN_ARRAYS_PTR.
Definition: gradstrc.cpp:507
Vector of double precision numbers.
Definition: dvector.h:50
ADMB variable vector.
Definition: fvar.hpp:2172
dvariable dpois(const double &k, const prevariable &lambda)
Definition: dpois.cpp:35
Library of statistic functions.
unsigned int size_count(const dvector &x)
Returns total size of elements in vector x.
Definition: dsize.cpp:17
void RETURN_ARRAYS_INCREMENT(void)
Increments gradient_structure::RETURN_ARRAYS_PTR.
Definition: gradstrc.cpp:474
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13