ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qfc_est.cpp
Go to the documentation of this file.
1 
39  #include "qfclib.h"
40 
41 
42 
43 
52  {
53  int dim;
54  dim=a.size()+1;
55  dvar_vector p(1,dim);
56  dvar_vector expa=mfexp(a);
57  p(1,dim-1)=expa/(1.+sum(expa));
58  //p(dim)=1.-sum(p(1,dim-1)); //original version was buggy for the last term
59  p(dim)=1./(1.+sum(expa));
60  return p;
61  }
63  {
64  int dim;
65  dim=size_count(a)+1;
66  df1b2vector p(1,dim);
67  df1b2vector expa=mfexp(a);
68  p(1,dim-1)=expa/(1.+sum(expa));
69  //p(dim)=1.-sum(p(1,dim-1)); //original version was buggy for the last term
70  p(dim)=1./(1.+sum(expa));
71  return p;
72  }
73 
74 
75 
76 
83  {
84  int dim;
85  dim=p.size()-1;
86  dvar_vector a(1,dim);
87  dvar_vector lp(1,dim+1);
88 
89  lp=log(p+EPS);//take log for each p
90  a=lp(1,dim)-lp(dim+1);//each subtract the last one
91  return a;
92  }
94  {
95  int dim;
96  dim=size_count(p)-1;
97  df1b2vector a(1,dim);
98  df1b2vector lp(1,dim+1);
99 
100  lp=log(p+EPS);//take log for each p
101  a=lp(1,dim)-lp(dim+1);//each subtract the last one
102  return a;
103  }
104 
105 
106 
107 
108 
116  {
117  dvariable psum=sum(p);
118  p/=psum; // Now the p will sum to 1
119  fpen+=1000.*square(log(psum)); //penalty
120  return p;
121  }
123  {
124  df1b2variable psum=sum(p);
125  p/=psum; // Now the p will sum to 1
126  fpen+=1000.*square(log(psum)); //penalty
127  return p;
128  }
129 
130 
131 
132 
142  dvar_vector posfun(dvar_vector& x,const dvector& eps, dvariable& pen) //x and eps both are vector
143  {
144  for(int i=x.indexmin();i<=x.indexmax();i++)
145  {
146  x(i)=posfun(x(i),eps(i),pen);
147  }
148  return x;
149  }
150  df1b2vector posfun(df1b2vector& x,const dvector& eps, df1b2variable& pen) //x and eps both are vector
151  {
152  for(int i=x.indexmin();i<=x.indexmax();i++)
153  {
154  x(i)=posfun(x(i),eps(i),pen);
155  }
156  return x;
157  }
158 
159 
160 
161 
173  {
174  for(int i=x.rowmin();i<=x.rowmax();i++)
175  {
176  for(int j=x.colmin();j<=x.colmax();j++)
177  {
178  x(i,j)=posfun(x(i,j),eps(i,j),pen);
179  }
180  }
181  return x;
182  }
184  {
185  for(int i=x.rowmin();i<=x.rowmax();i++)
186  {
187  for(int j=x.colmin();j<=x.colmax();j++)
188  {
189  x(i,j)=posfun(x(i,j),eps(i,j),pen);
190  }
191  }
192  return x;
193  }
194 
195 
196 
197 
198 
199 
210  dvariable mf_upper_bound2(const dvariable & x,const double fmax, dvariable & fpen)
211  {
212  if (value(x)<=fmax) return x;
213  else
214  {
215  fpen+=.01*square(x-fmax);
216  return x-x/(2.-fmax/x)+fmax;
217  }
218  }
219 
220  df1b2variable mf_upper_bound2(const df1b2variable & x,const double fmax, df1b2variable & fpen)
221  {
222  if (value(x)<=fmax) return x;
223  else
224  {
225  fpen+=.01*square(x-fmax);
226  return x-x/(2.-fmax/x)+fmax;
227  }
228  }
229 
230 
231 
232 
233 
243  dvar_vector boundp(const dvar_vector & x, const double fmin, const double fmax, const dvariable & fpen )
244  {
245  dvar_vector t(x.indexmin(),x.indexmax());
246  for(int i=x.indexmin();i<=x.indexmax();i++)
247  t(i)=boundp(x(i),fmin,fmax,fpen);
248  return (t);
249  }
250  df1b2vector boundp(const df1b2vector & x, const double fmin, const double fmax, const df1b2variable & fpen )
251  {
252  df1b2vector t(x.indexmin(),x.indexmax());
253  for(int i=x.indexmin();i<=x.indexmax();i++)
254  t(i)=boundp(x(i),fmin,fmax,fpen);
255  return (t);
256  }
257 
258 
259 
260 
261 
262 
263 
272  {
273  df1b2vector tmp(n.indexmin(),n.indexmax());
274  for(int i=n.indexmin();i<=n.indexmax();i++)
275  tmp(i)=log_comb(n(i),x(i));
276  return tmp;
277  }
279  {
280  df1b2vector tmp(n.indexmin(),n.indexmax());
281  for(int i=n.indexmin();i<=n.indexmax();i++)
282  tmp(i)=log_comb(n(i),x(i));
283  return tmp;
284  }
286  {
287  df1b2vector tmp(n.indexmin(),n.indexmax());
288  for(int i=n.indexmin();i<=n.indexmax();i++)
289  tmp(i)=log_comb(n(i),x(i));
290  return tmp;
291  }
292 
293 
294 
295 
296 
297 
298 
300  //
301  // Negative Binomial
302  //
304 
315  double nllNegativeBinomial(const double obs, const double m, const double s )
316  {
317  double nll=0;
318  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
319  return nll;
320  }
321  dvariable nllNegativeBinomial(const dvariable & obs, const double m, const double s )
322  {
324  dvariable nll=0;
325  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
327  return nll;
328  }
329  dvariable nllNegativeBinomial(const double obs, const dvariable & m, const dvariable & s)
330  {
332  dvariable nll=0;
333  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
335  return nll;
336  }
337  dvariable nllNegativeBinomial(const dvariable & obs, const dvariable & m, const double s)
338  {
340  dvariable nll=0;
341  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
343  return nll;
344  }
345  dvariable nllNegativeBinomial(const dvariable & obs, const double m, const dvariable & s)
346  {
348  dvariable nll=0;
349  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
351  return nll;
352  }
353  dvariable nllNegativeBinomial(const dvariable & obs, const dvariable & m, const dvariable & s)
354  {
356  dvariable nll=0;
357  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
359  return nll;
360  }
361 
372  df1b2variable nllNegativeBinomial(const df1b2variable & obs, const double m, const double s)
373  {
374  df1b2variable nll=.0;
375  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
376  return nll;
377  }
378  df1b2variable nllNegativeBinomial(const double obs, const df1b2variable & m, const df1b2variable & s)
379  {
380  df1b2variable nll=.0;
381  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
382  return nll;
383  }
384  df1b2variable nllNegativeBinomial(const df1b2variable & obs, const df1b2variable & m, const double s)
385  {
386  df1b2variable nll=.0;
387  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
388  return nll;
389  }
390  df1b2variable nllNegativeBinomial(const df1b2variable & obs, const double m, const df1b2variable & s)
391  {
392  df1b2variable nll=.0;
393  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
394  return nll;
395  }
397  {
398  df1b2variable nll=.0;
399  nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+ gammln(obs+1.);
400  return nll;
401  }
402 
403 
404 
405 
406 
417  dvariable nllNegativeBinomial(const dvector & obs, const dvariable & m, const dvariable & s)
418  {
420  dvariable nll=0;
421  double n=double(obs.size());
422  nll= -sum(gammln(obs+s))+ n*gammln(s)- n*s*log(s/(m+s)+EPS)- sum(obs)*log(m/(m+s)+EPS)+ sum(gammln(obs+1.));
424  return nll;
425  }
426  dvariable nllNegativeBinomial(const dvar_vector & obs, const double m, const double s)
427  {
429  dvariable nll=0;
430  double n=double(obs.size());
431  nll= -sum(gammln(obs+s))+ n*gammln(s)- n*s*log(s/(m+s)+EPS)- sum(obs)*log(m/(m+s)+EPS)+ sum(gammln(obs+1.));
433  return nll;
434  }
435  dvariable nllNegativeBinomial(const dvar_vector & obs, const dvariable & m, const dvariable & s)
436  {
438  dvariable nll=0;
439  double n=double(obs.size());
440  nll= -sum(gammln(obs+s))+ n*gammln(s)- n*s*log(s/(m+s)+EPS)- sum(obs)*log(m/(m+s)+EPS)+ sum(gammln(obs+1.));
442  return nll;
443  }
444 
455  df1b2variable nllNegativeBinomial(const df1b2vector & obs, const double m, const double s)
456  {
457  df1b2variable nll=.0;
458  double n=double(size_count(obs));
459  nll= -sum(gammln(obs+s))+ n*gammln(s)- n*s*log(s/(m+s)+EPS)- sum(obs)*log(m/(m+s)+EPS)+ sum(gammln(obs+1.));
460  return nll;
461  }
463  {
464  df1b2variable nll=.0;
465  double n=double(size_count(obs));
466  nll= -sum(gammln(obs+s))+ n*gammln(s)- n*s*log(s/(m+s)+EPS)- sum(obs)*log(m/(m+s)+EPS)+ sum(gammln(obs+1.));
467  return nll;
468  }
470  {
471  df1b2variable nll=.0;
472  double n=double(size_count(obs));
473  nll= -sum(gammln(obs+s))+ n*gammln(s)- n*s*log(s/(m+s)+EPS)- sum(obs)*log(m/(m+s)+EPS)+ sum(gammln(obs+1.));
474  return nll;
475  }
476 
477 
478 
479 
481  //
482  // Negative Binomial with tau
483  //
485 
495  double nllNegativeBinomial2(const double obs, const double m, const double tau)
496  {
497  return -log_density_negbinomial (obs,m,tau); //use admb built in function
498  }
499  dvariable nllNegativeBinomial2(const double obs, const dvariable & m, const dvariable & tau)
500  {
501  return -1.*log_negbinomial_density(obs,m,tau); //use admb built in function
502  }
503  dvariable nllNegativeBinomial2(const dvariable & obs, const double m, const double tau)
504  {
505  return nllNegativeBinomial(obs,m,m/(tau-1.+EPS));
506  }
507  dvariable nllNegativeBinomial2(const dvariable & obs, const dvariable & m, const double tau)
508  {
509  return nllNegativeBinomial(obs,m,m/(tau-1.+EPS));
510  }
511  dvariable nllNegativeBinomial2(const dvariable & obs, const double m, const dvariable & tau)
512  {
513  return nllNegativeBinomial(obs,m,m/(tau-1.+EPS));
514  }
515  dvariable nllNegativeBinomial2(const dvariable & obs, const dvariable & m, const dvariable & tau)
516  {
517  return nllNegativeBinomial(obs, m,m/(tau-1.+EPS));
518  }
519 
529  df1b2variable nllNegativeBinomial2(const df1b2variable & obs, const double m, const double tau)
530  {
531  return nllNegativeBinomial(obs,m,m/(tau-1.+EPS));
532  }
533  df1b2variable nllNegativeBinomial2(const double obs, const df1b2variable & m, const df1b2variable & tau)
534  {
535  return nllNegativeBinomial(obs,m,m/(tau-1.+EPS));
536  }
538  {
539  return nllNegativeBinomial(obs,m,m/(tau-1.+EPS));
540  }
541 
542 
543 
544 
545 
546 
548  //
549  // Multinomial
550  //
552 
560  double nllMultiNomial(const dvector & obsN, const dvector & p)
561  {
562  double nll=0;
563  nll= -1.*(obsN*log(p+EPS) + gammln(sum(obsN)+1.) - sum(gammln(obsN+1.))); //full likelihood
564  return nll;
565  }
566  dvariable nllMultiNomial(const dvector & obsN, const dvar_vector & p)
567  {
569  dvariable nll=0;
570  nll= -1.*(obsN*log(p+EPS) + gammln(sum(obsN)+1.) - sum(gammln(obsN+1.))); //full likelihood
572  return nll;
573  }
574  dvariable nllMultiNomial(const dvar_vector & obsN, const dvector & p)
575  {
577  dvariable nll=0;
578  nll= -1.*(obsN*log(p+EPS) + gammln(sum(obsN)+1.) - sum(gammln(obsN+1.))); //full likelihood
580  return nll;
581  }
583  {
585  dvariable nll=0;
586  nll= -1.*(obsN*log(p+EPS) + gammln(sum(obsN)+1.) - sum(gammln(obsN+1.))); //full likelihood
588  return nll;
589  }
590 
599  {
600  df1b2variable nll=.0;
601  nll= -1.*(obsN*log(p+EPS) + gammln(sum(obsN)+1.) - sum(gammln(obsN+1.))); //full likelihood
602  return nll;
603  }
605  {
606  df1b2variable nll=.0;
607  nll= -1.*(obsN*log(p+EPS) + gammln(sum(obsN)+1.) - sum(gammln(obsN+1.))); //full likelihood
608  return nll;
609  }
611  {
612  df1b2variable nll=.0;
613  nll= -1.*(obsN*log(p+EPS) + gammln(sum(obsN)+1.) - sum(gammln(obsN+1.))); //full likelihood
614  return nll;
615  }
616 
617 
618 
619 
621  //
622  // Dirichlet
623  //
625 
633  double nllDirichlet(const dvector & p, const dvector & shape)
634  {
635  double nll=0;
636  nll= -1.*(gammln(sum(shape)) - sum(gammln(shape)) + (shape-1.)*log(p+EPS));
637  return nll;
638  }
639  dvariable nllDirichlet(const dvar_vector & p, const dvector & shape)
640  {
642  dvariable nll=0;
643  nll= -1.*(gammln(sum(shape)) - sum(gammln(shape)) + (shape-1.)*log(p+EPS));
645  return nll;
646  }
647  dvariable nllDirichlet(const dvector & p, const dvar_vector & shape)
648  {
650  dvariable nll=0;
651  nll= -1.*(gammln(sum(shape)) - sum(gammln(shape)) + (shape-1.)*log(p+EPS));
653  return nll;
654  }
655  dvariable nllDirichlet(const dvar_vector & p, const dvar_vector & shape)
656  {
658  dvariable nll=0;
659  nll= -1.*(gammln(sum(shape)) - sum(gammln(shape)) + (shape-1.)*log(p+EPS));
661  return nll;
662  }
663 
671  df1b2variable nllDirichlet(const df1b2vector & p, const dvector & shape)
672  {
673  df1b2variable nll=.0;
674  nll= -1.*(gammln(sum(shape)) - sum(gammln(shape)) + (shape-1.)*log(p+EPS));
675  return nll;
676  }
677  df1b2variable nllDirichlet(const dvector & p, const df1b2vector & shape)
678  {
679  df1b2variable nll=.0;
680  nll= -1.*(gammln(sum(shape)) - sum(gammln(shape)) + (shape-1.)*log(p+EPS));
681  return nll;
682  }
684  {
685  df1b2variable nll=.0;
686  nll= -1.*(gammln(sum(shape)) - sum(gammln(shape)) + (shape-1.)*log(p+EPS));
687  return nll;
688  }
689 
690 
691 
692 
694  //
695  // Gamma
696  //
698 
708  double nllGamma(const double & x, const double a, const double b)
709  {
710  return -1.*log_gamma_density(x,a,b); //call admb built in function
711  }
712  dvariable nllGamma(const dvariable & x, const double a, const double b)
713  {
715  dvariable nll=0;
716  nll= gammln(a) - a*log(b) -(a-1.)*log(x+EPS) + b*x;
718  return nll;
719  }
720  dvariable nllGamma(const double x, const dvariable & a, const dvariable & b)
721  {
723  dvariable nll=0;
724  nll= gammln(a) - a*log(b) -(a-1.)*log(x+EPS) + b*x;
726  return nll;
727  }
728  dvariable nllGamma(const dvariable & x, const dvariable & a, const double b)
729  {
731  dvariable nll=0;
732  nll= gammln(a) - a*log(b) -(a-1.)*log(x+EPS) + b*x;
734  return nll;
735  }
736  dvariable nllGamma(const dvariable & x, const double a, const dvariable & b)
737  {
739  dvariable nll=0;
740  nll= gammln(a) - a*log(b) -(a-1.)*log(x+EPS) + b*x;
742  return nll;
743  }
744  dvariable nllGamma(const dvariable & x, const dvariable & a, const dvariable & b)
745  {
747  dvariable nll=0;
748  nll= gammln(a) - a*log(b) -(a-1.)*log(x+EPS) + b*x;
750  return nll;
751  }
752 
762  df1b2variable nllGamma(const df1b2variable & x, const double a, const double b)
763  {
764  df1b2variable nll=.0;
765  nll= gammln(a) - a*log(b) -(a-1.)*log(x+EPS) + b*x;
766  return nll;
767  }
768  df1b2variable nllGamma(const double x, const df1b2variable & a, const df1b2variable & b)
769  {
770  df1b2variable nll=.0;
771  nll= gammln(a) - a*log(b) -(a-1.)*log(x+EPS) + b*x;
772  return nll;
773  }
774  df1b2variable nllGamma(const df1b2variable & x, const df1b2variable & a, const double b)
775  {
776  df1b2variable nll=.0;
777  nll= gammln(a) - a*log(b) -(a-1.)*log(x+EPS) + b*x;
778  return nll;
779  }
780  df1b2variable nllGamma(const df1b2variable & x, const double a, const df1b2variable & b)
781  {
782  df1b2variable nll=.0;
783  nll= gammln(a) - a*log(b) -(a-1.)*log(x+EPS) + b*x;
784  return nll;
785  }
787  {
788  df1b2variable nll=.0;
789  nll= gammln(a) - a*log(b) -(a-1.)*log(x+EPS) + b*x;
790  return nll;
791  }
792 
793 
794 
803  double nllGamma(const dvector & x, const double a, const double b)
804  {
805  double nll=0;
806  double n=double(x.size());
807  nll=n*gammln(a) - n*a*log(b) -(a-1.)*sum(log(x+EPS)) + b*sum(x);
808  return nll;
809  }
810  dvariable nllGamma(const dvar_vector & x, const double a, const double b)
811  {
813  dvariable nll=0;
814  double n=double(x.size());
815  nll=n*gammln(a) - n*a*log(b) -(a-1.)*sum(log(x+EPS)) + b*sum(x);
817  return nll;
818  }
819  dvariable nllGamma(const dvector & x, const dvariable & a, const dvariable & b)
820  {
822  dvariable nll=0;
823  double n=double(x.size());
824  nll=n*gammln(a) - n*a*log(b) -(a-1.)*sum(log(x+EPS)) + b*sum(x);
826  return nll;
827  }
828  dvariable nllGamma(const dvar_vector & x, const dvariable & a, const dvariable & b)
829  {
831  dvariable nll=0;
832  double n=double(x.size());
833  nll=n*gammln(a) - n*a*log(b) -(a-1.)*sum(log(x+EPS)) + b*sum(x);
835  return nll;
836  }
837 
846  df1b2variable nllGamma(const df1b2vector & x, const double a, const double b)
847  {
848  df1b2variable nll=.0;
849  double n=double(size_count(x));
850  nll=n*gammln(a) - n*a*log(b) -(a-1.)*sum(log(x+EPS)) + b*sum(x);
851  return nll;
852  }
854  {
855  df1b2variable nll=.0;
856  double n=double(size_count(x));
857  nll=n*gammln(a) - n*a*log(b) -(a-1.)*sum(log(x+EPS)) + b*sum(x);
858  return nll;
859  }
861  {
862  df1b2variable nll=.0;
863  double n=double(size_count(x));
864  nll=n*gammln(a) - n*a*log(b) -(a-1.)*sum(log(x+EPS)) + b*sum(x);
865  return nll;
866  }
867 
868 
869 
870 
872  //
873  // Beta
874  //
876 
885  double nllBeta(const double x, const double a, const double b)
886  {
887  double nll=0;
888  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
889  return nll;
890  }
891  dvariable nllBeta(const dvariable & x, const double a, const double b)
892  {
894  dvariable nll=0;
895  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
897  return nll;
898  }
899  dvariable nllBeta(const double x, const dvariable & a, const dvariable & b)
900  {
902  dvariable nll=0;
903  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
905  return nll;
906  }
907  dvariable nllBeta(const dvariable & x, const dvariable & a, const double b)
908  {
910  dvariable nll=0;
911  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
913  return nll;
914  }
915  dvariable nllBeta(const dvariable & x, const double a, const dvariable & b)
916  {
918  dvariable nll=0;
919  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
921  return nll;
922  }
923  dvariable nllBeta(const dvariable & x, const dvariable & a, const dvariable & b)
924  {
926  dvariable nll=0;
927  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
929  return nll;
930  }
931 
940  df1b2variable nllBeta(const df1b2variable & x, const double a, const double b)
941  {
942  df1b2variable nll=.0;
943  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
944  return nll;
945  }
946  df1b2variable nllBeta(const df1b2variable & x, const df1b2variable & a, const double b)
947  {
948  df1b2variable nll=.0;
949  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
950  return nll;
951  }
952  df1b2variable nllBeta(const df1b2variable & x, const double a, const df1b2variable & b)
953  {
954  df1b2variable nll=.0;
955  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
956  return nll;
957  }
958  df1b2variable nllBeta(const double x, const df1b2variable & a, const df1b2variable & b)
959  {
960  df1b2variable nll=.0;
961  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
962  return nll;
963  }
965  {
966  df1b2variable nll=.0;
967  nll=gammln(a)+gammln(b)-gammln(a+b)-(a-1.)*log(x+EPS)-(b-1.)*log(1.-x+EPS);
968  return nll;
969  }
970 
971 
972 
981  dvariable nllBeta(const dvar_vector & x, const double a, const double b)
982  {
984  dvariable nll=0;
985  double n=double(x.size());
986  nll=n*gammln(a)+n*gammln(b)-n*gammln(a+b)-(a-1.)*sum(log(x+EPS))-(b-1.)*sum(log(1.-x+EPS));
988  return nll;
989  }
990  dvariable nllBeta(const dvector & x, const dvariable & a, const dvariable & b)
991  {
993  dvariable nll=0;
994  double n=double(x.size());
995  nll=n*gammln(a)+n*gammln(b)-n*gammln(a+b)-(a-1.)*sum(log(x+EPS))-(b-1.)*sum(log(1.-x+EPS));
997  return nll;
998  }
999  dvariable nllBeta(const dvar_vector & x, const dvariable & a, const dvariable & b)
1000  {
1002  dvariable nll=0;
1003  double n=double(x.size());
1004  nll=n*gammln(a)+n*gammln(b)-n*gammln(a+b)-(a-1.)*sum(log(x+EPS))-(b-1.)*sum(log(1.-x+EPS));
1006  return nll;
1007  }
1008 
1017  df1b2variable nllBeta(const df1b2vector & x, const double a, const double b)
1018  {
1019  df1b2variable nll=.0;
1020  double n=double(size_count(x));
1021  nll=n*gammln(a)+n*gammln(b)-n*gammln(a+b)-(a-1.)*sum(log(x+EPS))-(b-1.)*sum(log(1.-x+EPS));
1022  return nll;
1023  }
1025  {
1026  df1b2variable nll=.0;
1027  double n=double(size_count(x));
1028  nll=n*gammln(a)+n*gammln(b)-n*gammln(a+b)-(a-1.)*sum(log(x+EPS))-(b-1.)*sum(log(1.-x+EPS));
1029  return nll;
1030  }
1032  {
1033  df1b2variable nll=.0;
1034  double n=double(size_count(x));
1035  nll=n*gammln(a)+n*gammln(b)-n*gammln(a+b)-(a-1.)*sum(log(x+EPS))-(b-1.)*sum(log(1.-x+EPS));
1036  return nll;
1037  }
1038 
1039 
1040 
1041 
1043  //
1044  // Normal
1045  //
1047 
1056  double nllNormal(const double x, const double mu, const double sigma)
1057  {
1058  double nll=0;
1059  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1060  return nll;
1061  }
1062  dvariable nllNormal(const dvariable & x, const double mu, const double sigma)
1063  {
1065  dvariable nll=0;
1066  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1068  return nll;
1069  }
1070  dvariable nllNormal(const double x, const dvariable & mu, const dvariable & sigma)
1071  {
1073  dvariable nll=0;
1074  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1076  return nll;
1077  }
1078  dvariable nllNormal(const dvariable & x, const dvariable & mu, const double sigma)
1079  {
1081  dvariable nll=0;
1082  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1084  return nll;
1085  }
1086  dvariable nllNormal(const dvariable & x, const double mu, const dvariable & sigma)
1087  {
1089  dvariable nll=0;
1090  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1092  return nll;
1093  }
1094  dvariable nllNormal(const dvariable & x, const dvariable & mu, const dvariable & sigma)
1095  {
1097  dvariable nll=0;
1098  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1100  return nll;
1101  }
1102 
1111  df1b2variable nllNormal(const df1b2variable & x, const double mu, const double sigma)
1112  {
1113  df1b2variable nll=.0;
1114  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1115  return nll;
1116  }
1117  df1b2variable nllNormal(const df1b2variable & x, const df1b2variable & mu, const double sigma)
1118  {
1119  df1b2variable nll=.0;
1120  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1121  return nll;
1122  }
1123  df1b2variable nllNormal(const df1b2variable & x, const double mu, const df1b2variable & sigma)
1124  {
1125  df1b2variable nll=.0;
1126  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1127  return nll;
1128  }
1129  df1b2variable nllNormal(const double x, const df1b2variable & mu, const df1b2variable & sigma)
1130  {
1131  df1b2variable nll=.0;
1132  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1133  return nll;
1134  }
1136  {
1137  df1b2variable nll=.0;
1138  nll=log(sigma*sqrt(2.*M_PI)+EPS) +0.5*square((x-mu)/(sigma+EPS));
1139  return nll;
1140  }
1141 
1142 
1143 
1152  double nllNormal(const dvector & x, const double mu, const double sigma)
1153  {
1154  double nll=0;
1155  double n=double(x.size());
1156  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1157  return nll;
1158  }
1159  dvariable nllNormal(const dvar_vector& x, const double mu, const double sigma)
1160  {
1162  dvariable nll=0;
1163  double n=double(x.size());
1164  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1166  return nll;
1167  }
1168  dvariable nllNormal(const dvector & x, const dvariable & mu, const dvariable & sigma)
1169  {
1171  dvariable nll=0;
1172  double n=double(x.size());
1173  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1175  return nll;
1176  }
1177  dvariable nllNormal(const dvar_vector & x, const dvariable & mu, const dvariable & sigma)
1178  {
1180  dvariable nll=0;
1181  double n=double(x.size());
1182  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1184  return nll;
1185  }
1186 
1195  df1b2variable nllNormal(const df1b2vector & x, const double mu, const double sigma)
1196  {
1197  df1b2variable nll=.0;
1198  double n=double(size_count(x));
1199  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1200  return nll;
1201  }
1202  df1b2variable nllNormal(const dvector & x, const df1b2variable & mu, const df1b2variable & sigma)
1203  {
1204  df1b2variable nll=.0;
1205  double n=double(size_count(x));
1206  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1207  return nll;
1208  }
1209  df1b2variable nllNormal(const df1b2vector & x, const df1b2variable & mu, const df1b2variable & sigma)
1210  {
1211  df1b2variable nll=.0;
1212  double n=double(size_count(x));
1213  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1214  return nll;
1215  }
1216 
1217 
1218 
1227  dvariable nllNormal(const dvar_vector & x, const dvector & mu, const double sigma)
1228  {
1230  dvariable nll=0;
1231  double n=double(x.size());
1232  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1234  return nll;
1235  }
1236  dvariable nllNormal(const dvector & x, const dvar_vector & mu, const dvariable & sigma)
1237  {
1239  dvariable nll=0;
1240  double n=double(x.size());
1241  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1243  return nll;
1244  }
1245  dvariable nllNormal(const dvar_vector & x, const dvar_vector & mu, const dvariable & sigma)
1246  {
1248  dvariable nll=0;
1249  double n=double(x.size());
1250  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1252  return nll;
1253  }
1254 
1263  df1b2variable nllNormal(const df1b2vector & x, const dvector & mu, const double sigma)
1264  {
1265  df1b2variable nll=.0;
1266  double n=double(size_count(x));
1267  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1268  return nll;
1269  }
1270  df1b2variable nllNormal(const dvector & x, const df1b2vector & mu, const df1b2variable & sigma)
1271  {
1272  df1b2variable nll=.0;
1273  double n=double(size_count(x));
1274  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1275  return nll;
1276  }
1277  df1b2variable nllNormal(const df1b2vector & x, const df1b2vector & mu, const df1b2variable & sigma)
1278  {
1279  df1b2variable nll=.0;
1280  double n=double(size_count(x));
1281  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +0.5*norm2((x-mu)/(sigma+EPS));
1282  return nll;
1283  }
1284 
1285 
1286 
1287 
1288 
1289 
1291  //
1292  // Normal with tau
1293  //
1295 
1304  dvariable nllNormal2(const dvariable & x, const double mu, const double tau)
1305  {
1307  dvariable nll=0;
1308  nll = -0.5*log(tau+EPS)+0.5*tau*square(x-mu)+0.5*log(2.*M_PI);//full likelihood, can drop last term
1310  return nll;
1311  }
1312  dvariable nllNormal2(const double x, const dvariable & mu, const dvariable & tau)
1313  {
1315  dvariable nll=0;
1316  nll = -0.5*log(tau+EPS)+0.5*tau*square(x-mu)+0.5*log(2.*M_PI);//full likelihood, can drop last term
1318  return nll;
1319  }
1320  dvariable nllNormal2(const dvariable & x, const dvariable & mu, const dvariable & tau)
1321  {
1323  dvariable nll=0;
1324  nll = -0.5*log(tau+EPS)+0.5*tau*square(x-mu)+0.5*log(2.*M_PI);//full likelihood, can drop last term
1326  return nll;
1327  }
1328 
1337  df1b2variable nllNormal2(const df1b2variable & x, const double mu, const double tau)
1338  {
1339  df1b2variable nll=.0;
1340  nll = -0.5*log(tau+EPS)+0.5*tau*square(x-mu)+0.5*log(2.*M_PI);//full likelihood, can drop last term
1341  return nll;
1342  }
1343  df1b2variable nllNormal2(const double x, const df1b2variable & mu, const df1b2variable & tau)
1344  {
1345  df1b2variable nll=.0;
1346  nll = -0.5*log(tau+EPS)+0.5*tau*square(x-mu)+0.5*log(2.*M_PI);//full likelihood, can drop last term
1347  return nll;
1348  }
1350  {
1351  df1b2variable nll=.0;
1352  nll = -0.5*log(tau+EPS)+0.5*tau*square(x-mu)+0.5*log(2.*M_PI);//full likelihood, can drop last term
1353  return nll;
1354  }
1355 
1356 
1357 
1358 
1367  dvariable nllNormal2(const dvar_vector & x, const double mu, const double tau)
1368  {
1370  dvariable nll=0;
1371  double n=double(x.size());
1372  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);//full likelihood, can drop last term
1374  return nll;
1375  }
1376  dvariable nllNormal2(const dvector & x, const dvariable & mu, const dvariable & tau)
1377  {
1379  dvariable nll=0;
1380  double n=double(x.size());
1381  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);//full likelihood, can drop last term
1383  return nll;
1384  }
1385  dvariable nllNormal2(const dvar_vector & x, const dvariable & mu, const dvariable & tau)
1386  {
1388  dvariable nll=0;
1389  double n=double(x.size());
1390  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);//full likelihood, can drop last term
1392  return nll;
1393  }
1394 
1403  df1b2variable nllNormal2(const df1b2vector & x, const double mu, const double tau)
1404  {
1405  df1b2variable nll=.0;
1406  double n=double(size_count(x));
1407  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);//full likelihood, can drop last term
1408  return nll;
1409  }
1410  df1b2variable nllNormal2(const dvector & x, const df1b2variable & mu, const df1b2variable & tau)
1411  {
1412  df1b2variable nll=.0;
1413  double n=double(size_count(x));
1414  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);//full likelihood, can drop last term
1415  return nll;
1416  }
1418  {
1419  df1b2variable nll=.0;
1420  double n=double(size_count(x));
1421  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);//full likelihood, can drop last term
1422  return nll;
1423  }
1424 
1425 
1426 
1435  dvariable nllNormal2(const dvar_vector & x, const dvector & mu, const double tau)
1436  {
1438  dvariable nll=0;
1439  double n=double(x.size());
1440  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);
1442  return nll;
1443  }
1444  dvariable nllNormal2(const dvector & x, const dvar_vector & mu, const dvariable & tau)
1445  {
1447  dvariable nll=0;
1448  double n=double(x.size());
1449  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);
1451  return nll;
1452  }
1453  dvariable nllNormal2(const dvar_vector & x, const dvar_vector & mu, const dvariable & tau)
1454  {
1456  dvariable nll=0;
1457  double n=double(x.size());
1458  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);
1460  return nll;
1461  }
1462 
1471  df1b2variable nllNormal2(const df1b2vector & x, const dvector & mu, const double tau)
1472  {
1473  df1b2variable nll=.0;
1474  double n=double(size_count(x));
1475  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);
1476  return nll;
1477  }
1478  df1b2variable nllNormal2(const dvector & x, const df1b2vector & mu, const df1b2variable & tau)
1479  {
1480  df1b2variable nll=.0;
1481  double n=double(size_count(x));
1482  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);
1483  return nll;
1484  }
1486  {
1487  df1b2variable nll=.0;
1488  double n=double(size_count(x));
1489  nll = -0.5*n*log(tau+EPS)+0.5*tau*norm2(x-mu)+0.5*n*log(2.*M_PI);
1490  return nll;
1491  }
1492 
1493 
1494 
1495 
1496 
1497 
1498 
1500  //
1501  // Binomial
1502  //
1504 
1513  double nllBinomial(const double x, const double n,const double p)
1514  {
1515  double nll=0;
1516  nll=-x*log(p+EPS)-(n-x)*log(1.-p+EPS)-log_comb(n,x); //full likelihood, can drop the last term
1517  return nll;
1518  }
1519  dvariable nllBinomial(const dvariable & x, const double n,const double p)
1520  {
1522  dvariable nll=0;
1523  nll=-x*log(p+EPS)-(n-x)*log(1.-p+EPS)-log_comb(n,x); //full likelihood, can drop the last term
1525  return nll;
1526  }
1527  dvariable nllBinomial(const double x, const dvariable & n,const dvariable & p)
1528  {
1530  dvariable nll=0;
1531  nll=-x*log(p+EPS)-(n-x)*log(1.-p+EPS)-log_comb(n,x); //full likelihood, can drop the last term
1533  return nll;
1534  }
1535  dvariable nllBinomial(const dvariable & x, const dvariable & n,const dvariable & p)
1536  {
1538  dvariable nll=0;
1539  nll=-x*log(p+EPS)-(n-x)*log(1.-p+EPS)-log_comb(n,x); //full likelihood, can drop the last term
1541  return nll;
1542  }
1543 
1552  df1b2variable nllBinomial(const df1b2variable & x, const double n,const double p)
1553  {
1554  df1b2variable nll=.0;
1555  nll=-x*log(p+EPS)-(n-x)*log(1.-p+EPS)-log_comb(n,x); //full likelihood, can drop the last term
1556  return nll;
1557  }
1558  df1b2variable nllBinomial(const double x, const df1b2variable & n,const df1b2variable & p)
1559  {
1560  df1b2variable nll=.0;
1561  nll=-x*log(p+EPS)-(n-x)*log(1.-p+EPS)-log_comb(n,x); //full likelihood, can drop the last term
1562  return nll;
1563  }
1565  {
1566  df1b2variable nll=.0;
1567  nll=-x*log(p+EPS)-(n-x)*log(1.-p+EPS)-log_comb(n,x); //full likelihood, can drop the last term
1568  return nll;
1569  }
1570 
1571 
1572 
1573 
1582  dvariable nllBinomial(const dvar_vector & x, const dvector & n,const double p)
1583  {
1585  dvariable nll=0;
1586  nll=-sum(x)*log(p+EPS)-sum(n-x)*log(1.-p+EPS)-sum(log_comb(n,x)); //full likelihood, can drop the last term
1588  return nll;
1589  }
1590  dvariable nllBinomial(const dvector & x, const dvar_vector & n,const dvariable & p)
1591  {
1593  dvariable nll=0;
1594  nll=-sum(x)*log(p+EPS)-sum(n-x)*log(1.-p+EPS)-sum(log_comb(n,x)); //full likelihood, can drop the last term
1596  return nll;
1597  }
1598  dvariable nllBinomial(const dvar_vector & x, const dvar_vector & n,const dvariable & p)
1599  {
1601  dvariable nll=0;
1602  nll=-sum(x)*log(p+EPS)-sum(n-x)*log(1.-p+EPS)-sum(log_comb(n,x)); //full likelihood, can drop the last term
1604  return nll;
1605  }
1606 
1616  {
1617  df1b2variable nll=.0;
1618  nll=-sum(x)*log(p+EPS)-sum(n-x)*log(1.-p+EPS)-sum(log_comb(n,x)); //full likelihood, can drop the last term
1619  return nll;
1620  }
1621  df1b2variable nllBinomial(const df1b2vector & x, const dvector & n,const double p)
1622  {
1623  df1b2variable nll=.0;
1624  nll=-sum(x)*log(p+EPS)-sum(n-x)*log(1.-p+EPS)-sum(log_comb(n,x)); //full likelihood, can drop the last term
1625  return nll;
1626  }
1628  {
1629  df1b2variable nll=.0;
1630  nll=-sum(x)*log(p+EPS)-sum(n-x)*log(1.-p+EPS)-sum(log_comb(n,x)); //full likelihood, can drop the last term
1631  return nll;
1632  }
1633 
1634 
1635 
1636 
1637 
1638 
1639 
1640 
1642  //
1643  // Lognormal
1644  //
1646 
1655  double nllLognormal(const double x, const double mu, const double sigma)
1656  {
1657  double nll=0;
1658  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1659  return nll;
1660  }
1661  dvariable nllLognormal(const dvariable& x, const double mu, const double sigma)
1662  {
1664  dvariable nll=0;
1665  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1667  return nll;
1668  }
1669  dvariable nllLognormal(const double x, const dvariable & mu, const dvariable & sigma)
1670  {
1672  dvariable nll=0;
1673  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1675  return nll;
1676  }
1677  dvariable nllLognormal(const dvariable & x, const dvariable & mu, const double sigma)
1678  {
1680  dvariable nll=0;
1681  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1683  return nll;
1684  }
1685  dvariable nllLognormal(const dvariable & x, const double mu, const dvariable & sigma)
1686  {
1688  dvariable nll=0;
1689  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1691  return nll;
1692  }
1693  dvariable nllLognormal(const dvariable & x, const dvariable & mu, const dvariable & sigma)
1694  {
1696  dvariable nll=0;
1697  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1699  return nll;
1700  }
1701 
1710  df1b2variable nllLognormal(const df1b2variable & x, const double mu, const double sigma)
1711  {
1712  df1b2variable nll=.0;
1713  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1714  return nll;
1715  }
1716  df1b2variable nllLognormal(const double x, const df1b2variable & mu, const df1b2variable & sigma)
1717  {
1718  df1b2variable nll=.0;
1719  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1720  return nll;
1721  }
1722  df1b2variable nllLognormal(const df1b2variable & x, const df1b2variable & mu, const double sigma)
1723  {
1724  df1b2variable nll=.0;
1725  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1726  return nll;
1727  }
1728  df1b2variable nllLognormal(const df1b2variable & x, const double mu, const df1b2variable & sigma)
1729  {
1730  df1b2variable nll=.0;
1731  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1732  return nll;
1733  }
1735  {
1736  df1b2variable nll=.0;
1737  nll=log(sigma*sqrt(2.*M_PI)+EPS)+log(x+EPS)+0.5*square((log(x+EPS)-mu)/(sigma+EPS));//full likelihood
1738  return nll;
1739  }
1740 
1741 
1742 
1743 
1752  dvariable nllLognormal(const dvar_vector & x, const double mu, const double sigma)
1753  {
1755  dvariable nll=0;
1756  double n=double(x.size());
1757  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1759  return nll;
1760  }
1761  dvariable nllLognormal(const dvector & x, const dvariable & mu, const dvariable & sigma)
1762  {
1764  dvariable nll=0;
1765  double n=double(x.size());
1766  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1768  return nll;
1769  }
1770  dvariable nllLognormal(const dvar_vector & x, const dvariable & mu, const dvariable & sigma)
1771  {
1773  dvariable nll=0;
1774  double n=double(x.size());
1775  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1777  return nll;
1778  }
1779 
1788  df1b2variable nllLognormal(const df1b2vector & x, const double mu, const double sigma)
1789  {
1790  df1b2variable nll=.0;
1791  double n=double(size_count(x));
1792  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1793  return nll;
1794  }
1795  df1b2variable nllLognormal(const dvector & x, const df1b2variable & mu, const df1b2variable & sigma)
1796  {
1797  df1b2variable nll=.0;
1798  double n=double(size_count(x));
1799  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1800  return nll;
1801  }
1803  {
1804  df1b2variable nll=.0;
1805  double n=double(size_count(x));
1806  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1807  return nll;
1808  }
1809 
1810 
1811 
1820  dvariable nllLognormal(const dvar_vector & x, const dvector & mu, const double sigma)
1821  {
1823  dvariable nll=0;
1824  double n=double(x.size());
1825  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1827  return nll;
1828  }
1829  dvariable nllLognormal(const dvector & x, const dvar_vector & mu, const dvariable & sigma)
1830  {
1832  dvariable nll=0;
1833  double n=double(x.size());
1834  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1836  return nll;
1837  }
1838  dvariable nllLognormal(const dvar_vector & x, const dvar_vector & mu, const dvariable & sigma)
1839  {
1841  dvariable nll=0;
1842  double n=double(x.size());
1843  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1845  return nll;
1846  }
1847 
1856  df1b2variable nllLognormal(const df1b2vector & x, const dvector & mu, const double sigma)
1857  {
1858  df1b2variable nll=.0;
1859  double n=double(size_count(x));
1860  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1861  return nll;
1862  }
1863  df1b2variable nllLognormal(const dvector & x, const df1b2vector & mu, const df1b2variable & sigma)
1864  {
1865  df1b2variable nll=.0;
1866  double n=double(size_count(x));
1867  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1868  return nll;
1869  }
1870  df1b2variable nllLognormal(const df1b2vector & x, const df1b2vector & mu, const df1b2variable & sigma)
1871  {
1872  df1b2variable nll=.0;
1873  double n=double(size_count(x));
1874  nll=n*log(sigma*sqrt(2.*M_PI)+EPS) +sum(log(x+EPS))+0.5*norm2((log(x+EPS)-mu)/(sigma+EPS));
1875  return nll;
1876  }
1877 
1878 
1879 
1880 
1881 
1882 
1884  //
1885  // Lognormal with tau
1886  //
1888 
1897  dvariable nllLognormal2(const double x, const dvariable & mu, const dvariable & tau)
1898  {
1900  dvariable nll=0;
1901  nll= -0.5*log(tau+EPS)+log(x+EPS)+0.5*tau*square(log(x+EPS)-mu)+0.5*log(2.*M_PI);//full likelihood
1903  return nll;
1904  }
1905  dvariable nllLognormal2(const dvariable & x, const double mu, const double tau)
1906  {
1908  dvariable nll=0;
1909  nll= -0.5*log(tau+EPS)+log(x+EPS)+0.5*tau*square(log(x+EPS)-mu)+0.5*log(2.*M_PI);//full likelihood
1911  return nll;
1912  }
1913  dvariable nllLognormal2(const dvariable & x, const dvariable & mu, const dvariable & tau)
1914  {
1916  dvariable nll=0;
1917  nll= -0.5*log(tau+EPS)+log(x+EPS)+0.5*tau*square(log(x+EPS)-mu)+0.5*log(2.*M_PI);//full likelihood
1919  return nll;
1920  }
1921 
1930  df1b2variable nllLognormal2(const df1b2variable x, const double mu, const double tau)
1931  {
1932  df1b2variable nll=.0;
1933  nll= -0.5*log(tau+EPS)+log(x+EPS)+0.5*tau*square(log(x+EPS)-mu)+0.5*log(2.*M_PI);//full likelihood
1934  return nll;
1935  }
1936  df1b2variable nllLognormal2(const double x, const df1b2variable & mu, const df1b2variable & tau)
1937  {
1938  df1b2variable nll=.0;
1939  nll= -0.5*log(tau+EPS)+log(x+EPS)+0.5*tau*square(log(x+EPS)-mu)+0.5*log(2.*M_PI);//full likelihood
1940  return nll;
1941  }
1942  df1b2variable nllLognormal2(const df1b2variable x, const df1b2variable & mu, const double tau)
1943  {
1944  df1b2variable nll=.0;
1945  nll= -0.5*log(tau+EPS)+log(x+EPS)+0.5*tau*square(log(x+EPS)-mu)+0.5*log(2.*M_PI);//full likelihood
1946  return nll;
1947  }
1948  df1b2variable nllLognormal2(const df1b2variable x, const double mu, const df1b2variable & tau)
1949  {
1950  df1b2variable nll=.0;
1951  nll= -0.5*log(tau+EPS)+log(x+EPS)+0.5*tau*square(log(x+EPS)-mu)+0.5*log(2.*M_PI);//full likelihood
1952  return nll;
1953  }
1955  {
1956  df1b2variable nll=.0;
1957  nll= -0.5*log(tau+EPS)+log(x+EPS)+0.5*tau*square(log(x+EPS)-mu)+0.5*log(2.*M_PI);//full likelihood
1958  return nll;
1959  }
1960 
1961 
1962 
1963 
1972  dvariable nllLognormal2(const dvar_vector & x, const double mu, const double tau)
1973  {
1975  dvariable nll=0;
1976  double n=double(x.size());
1977  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
1979  return nll;
1980  }
1981  dvariable nllLognormal2(const dvector & x, const dvariable & mu, const dvariable & tau)
1982  {
1984  dvariable nll=0;
1985  double n=double(x.size());
1986  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
1988  return nll;
1989  }
1990  dvariable nllLognormal2(const dvar_vector & x, const dvariable & mu, const dvariable & tau)
1991  {
1993  dvariable nll=0;
1994  double n=double(x.size());
1995  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
1997  return nll;
1998  }
1999 
2009  {
2010  df1b2variable nll=.0;
2011  double n=double(size_count(x));
2012  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2013  return nll;
2014  }
2015  df1b2variable nllLognormal2(const df1b2vector & x, const double mu, const double tau)
2016  {
2017  df1b2variable nll=.0;
2018  double n=double(size_count(x));
2019  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2020  return nll;
2021  }
2022  df1b2variable nllLognormal2(const df1b2vector & x, const df1b2variable & mu, const double tau)
2023  {
2024  df1b2variable nll=.0;
2025  double n=double(size_count(x));
2026  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2027  return nll;
2028  }
2029  df1b2variable nllLognormal2(const df1b2vector & x, const double mu, const df1b2variable & tau)
2030  {
2031  df1b2variable nll=.0;
2032  double n=double(size_count(x));
2033  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2034  return nll;
2035  }
2037  {
2038  df1b2variable nll=.0;
2039  double n=double(size_count(x));
2040  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2041  return nll;
2042  }
2043 
2044 
2045 
2046 
2055  dvariable nllLognormal2(const dvar_vector & x, const dvector & mu, const double tau)
2056  {
2058  dvariable nll=0;
2059  double n=double(x.size());
2060  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2062  return nll;
2063  }
2064  dvariable nllLognormal2(const dvector & x, const dvar_vector & mu, const dvariable & tau)
2065  {
2067  dvariable nll=0;
2068  double n=double(x.size());
2069  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2071  return nll;
2072  }
2073  dvariable nllLognormal2(const dvar_vector & x, const dvar_vector & mu, const dvariable & tau)
2074  {
2076  dvariable nll=0;
2077  double n=double(x.size());
2078  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2080  return nll;
2081  }
2082 
2091  df1b2variable nllLognormal2(const df1b2vector & x, const dvector & mu, const double tau)
2092  {
2093  df1b2variable nll=.0;
2094  double n=double(size_count(x));
2095  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2096  return nll;
2097  }
2098  df1b2variable nllLognormal2(const dvector & x, const df1b2vector & mu, const df1b2variable & tau)
2099  {
2100  df1b2variable nll=.0;
2101  double n=double(size_count(x));
2102  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2103  return nll;
2104  }
2106  {
2107  df1b2variable nll=.0;
2108  double n=double(size_count(x));
2109  nll=-0.5*n*log(tau+EPS)+sum(log(x+EPS))+0.5*tau*norm2(log(x+EPS)-mu)+0.5*n*log(2.*M_PI);
2110  return nll;
2111  }
2112 
2113 
2114 
2115 
2116 
2117 
2118 
2120  //
2121  // Poisson
2122  //
2124 
2132  double nllPoisson(const double x, const double lambda)
2133  {
2134  double nll=0;
2135  nll = lambda- x*log(lambda+EPS)+gammln(x+1.0);//full likelihood
2136  return nll;
2137  }
2138  dvariable nllPoisson(const dvariable & x, const double lambda)
2139  {
2141  dvariable nll=0;
2142  nll = lambda- x*log(lambda+EPS)+gammln(x+1.0);//full likelihood
2144  return nll;
2145  }
2146  dvariable nllPoisson(const double x, const dvariable & lambda)
2147  {
2149  dvariable nll=0;
2150  nll = lambda- x*log(lambda+EPS)+gammln(x+1.0);//full likelihood
2152  return nll;
2153  }
2154  dvariable nllPoisson(const dvariable & x, const dvariable & lambda)
2155  {
2157  dvariable nll=0;
2158  nll = lambda- x*log(lambda+EPS)+gammln(x+1.0);//full likelihood
2160  return nll;
2161  }
2162 
2170  df1b2variable nllPoisson(const df1b2variable & x, const double lambda)
2171  {
2172  df1b2variable nll=.0;
2173  nll = lambda- x*log(lambda+EPS)+gammln(x+1.0);//full likelihood
2174  return nll;
2175  }
2176  df1b2variable nllPoisson(const double x, const df1b2variable & lambda)
2177  {
2178  df1b2variable nll=.0;
2179  nll = lambda- x*log(lambda+EPS)+gammln(x+1.0);//full likelihood
2180  return nll;
2181  }
2183  {
2184  df1b2variable nll=.0;
2185  nll = lambda- x*log(lambda+EPS)+gammln(x+1.0);//full likelihood
2186  return nll;
2187  }
2188 
2189 
2190 
2198  dvariable nllPoisson(const dvar_vector & x, const double lambda)
2199  {
2201  dvariable nll=0;
2202  double n=double(x.size());
2203  nll = n*lambda- sum(x)*log(lambda+EPS)+sum(gammln(x+1.0));//full likelihood, can drop the last term
2205  return nll;
2206  }
2207  dvariable nllPoisson(const dvector & x, const dvariable & lambda)
2208  {
2210  dvariable nll=0;
2211  double n=double(x.size());
2212  nll = n*lambda- sum(x)*log(lambda+EPS)+sum(gammln(x+1.0));//full likelihood, can drop the last term
2214  return nll;
2215  }
2216  dvariable nllPoisson(const dvar_vector & x, const dvariable & lambda)
2217  {
2219  dvariable nll=0;
2220  double n=double(x.size());
2221  nll = n*lambda- sum(x)*log(lambda+EPS)+sum(gammln(x+1.0));//full likelihood, can drop the last term
2223  return nll;
2224  }
2225 
2234  {
2235  df1b2variable nll=.0;
2236  double n=double(size_count(x));
2237  nll = n*lambda- sum(x)*log(lambda+EPS)+sum(gammln(x+1.0));//full likelihood, can drop the last term
2238  return nll;
2239  }
2240  df1b2variable nllPoisson(const df1b2vector & x, const double lambda)
2241  {
2242  df1b2variable nll=.0;
2243  double n=double(size_count(x));
2244  nll = n*lambda- sum(x)*log(lambda+EPS)+sum(gammln(x+1.0));//full likelihood, can drop the last term
2245  return nll;
2246  }
2248  {
2249  df1b2variable nll=.0;
2250  double n=double(size_count(x));
2251  nll = n*lambda- sum(x)*log(lambda+EPS)+sum(gammln(x+1.0));//full likelihood, can drop the last term
2252  return nll;
2253  }
2254 
2255 
2256 
2257 
2258 
2259 
2261  //
2262  // Inverse Gamma
2263  //
2265 
2274  double nllInverseGamma(const double x, const double a, const double b)
2275  {
2276  double nll=0;
2277  nll= - a*log(b)+gammln(a) +(a+1.)*log(x+EPS) + b/(x+EPS);
2278  return nll;
2279  }
2280  dvariable nllInverseGamma(const dvariable & x, const double a, const double b)
2281  {
2283  dvariable nll=0;
2284  nll= - a*log(b)+gammln(a) +(a+1.)*log(x+EPS) + b/(x+EPS);
2286  return nll;
2287  }
2288  dvariable nllInverseGamma(const double x, const dvariable & a, const dvariable & b)
2289  {
2291  dvariable nll=0;
2292  nll= - a*log(b)+gammln(a) +(a+1.)*log(x+EPS) + b/(x+EPS);
2294  return nll;
2295  }
2296  dvariable nllInverseGamma(const dvariable & x, const dvariable & a, const dvariable & b)
2297  {
2299  dvariable nll=0;
2300  nll= - a*log(b)+gammln(a) +(a+1.)*log(x+EPS) + b/(x+EPS);
2302  return nll;
2303  }
2304 
2313  df1b2variable nllInverseGamma(const df1b2variable & x, const double a, const double b)
2314  {
2315  df1b2variable nll=.0;
2316  nll= - a*log(b)+gammln(a) +(a+1.)*log(x+EPS) + b/(x+EPS);
2317  return nll;
2318  }
2319  df1b2variable nllInverseGamma(const double x, const df1b2variable & a, const df1b2variable & b)
2320  {
2321  df1b2variable nll=.0;
2322  nll= - a*log(b)+gammln(a) +(a+1.)*log(x+EPS) + b/(x+EPS);
2323  return nll;
2324  }
2325  df1b2variable nllInverseGamma(const df1b2variable & x, const df1b2variable & a, const double b)
2326  {
2327  df1b2variable nll=.0;
2328  nll= - a*log(b)+gammln(a) +(a+1.)*log(x+EPS) + b/(x+EPS);
2329  return nll;
2330  }
2331  df1b2variable nllInverseGamma(const df1b2variable & x, const double a, const df1b2variable & b)
2332  {
2333  df1b2variable nll=.0;
2334  nll= - a*log(b)+gammln(a) +(a+1.)*log(x+EPS) + b/(x+EPS);
2335  return nll;
2336  }
2338  {
2339  df1b2variable nll=.0;
2340  nll= - a*log(b)+gammln(a) +(a+1.)*log(x+EPS) + b/(x+EPS);
2341  return nll;
2342  }
2343 
2344 
2345 
2346 
2355  dvariable nllInverseGamma(const dvar_vector & x, const double a, const double b)
2356  {
2358  dvariable nll=0;
2359  double n=double(x.size());
2360  nll= - n*a*log(b)+ n*gammln(a) +(a+1.)*sum(log(x+EPS)) + b/sum(x+EPS);
2362  return nll;
2363  }
2364  dvariable nllInverseGamma(const dvector & x, const dvariable & a, const dvariable & b)
2365  {
2367  dvariable nll=0;
2368  double n=double(x.size());
2369  nll= - n*a*log(b)+ n*gammln(a) +(a+1.)*sum(log(x+EPS)) + b/sum(x+EPS);
2371  return nll;
2372  }
2374  {
2376  dvariable nll=0;
2377  double n=double(x.size());
2378  nll= - n*a*log(b)+ n*gammln(a) +(a+1.)*sum(log(x+EPS)) + b/sum(x+EPS);
2380  return nll;
2381  }
2382 
2392  {
2393  df1b2variable nll=.0;
2394  double n=double(size_count(x));
2395  nll= - n*a*log(b)+ n*gammln(a) +(a+1.)*sum(log(x+EPS)) + b/sum(x+EPS);
2396  return nll;
2397  }
2398  df1b2variable nllInverseGamma(const df1b2vector & x, const double a, const double b)
2399  {
2400  df1b2variable nll=.0;
2401  double n=double(size_count(x));
2402  nll= - n*a*log(b)+ n*gammln(a) +(a+1.)*sum(log(x+EPS)) + b/sum(x+EPS);
2403  return nll;
2404  }
2406  {
2407  df1b2variable nll=.0;
2408  double n=double(size_count(x));
2409  nll= - n*a*log(b)+ n*gammln(a) +(a+1.)*sum(log(x+EPS)) + b/sum(x+EPS);
2410  return nll;
2411  }
double nllGamma(const double &x, const double a, const double b)
nll for gamma for one sample Gamma(a,b) similar to log_gamma_density(r,mu) in admb, in which a=r, b=mu
Definition: qfc_est.cpp:708
dvar_vector normalize_p(dvar_vector &p, dvariable fpen)
normailize p as sum(p)=1, return p and penalty if sum(p)!=1
Definition: qfc_est.cpp:115
double log_comb(double n, double k)
Log of the binomial coefficent; i.e log of &#39;n choose k&#39;.
Definition: combc.cpp:27
int rowmax(void) const
Definition: fvar.hpp:2564
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
int colmin(void) const
Definition: fvar.hpp:2552
#define x
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
void fmin(double f, const independent_variables &x, const dvector &g, const int &n, const dvector &w, const dvector &h, const fmm_control &fmc)
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
Description not yet available.
Definition: df1b2fun.h:953
int indexmin(void) const
Definition: df1b2fun.h:969
dvariable nllLognormal2(const double x, const dvariable &mu, const dvariable &tau)
nll for lognormal(mu,tau) for one sample
Definition: qfc_est.cpp:1897
double nllNegativeBinomial2(const double obs, const double m, const double tau)
nll for negative binomial N(mu,tau) for one sample, admb built in log_negbinomial_density(obs,mu,tau), in which tau=1.
Definition: qfc_est.cpp:495
dvar_vector posfun(const dvar_vector &x, double eps, const prevariable &pen)
Description not yet available.
Definition: fvar_a62.cpp:17
ADMB variable vector.
Definition: fvar.hpp:2172
int rowmin(void) const
Definition: df1b2fun.h:1053
unsigned int size() const
Definition: fvar.hpp:2297
dvariable nllNormal2(const dvariable &x, const double mu, const double tau)
nll for normal(mu,tau) for one sample
Definition: qfc_est.cpp:1304
double nllNormal(const double x, const double mu, const double sigma)
nll for normal for one sample
Definition: qfc_est.cpp:1056
Description not yet available.
Definition: df1b2fun.h:266
const double EPS
Definition: qfclib.h:42
d3_array mfexp(const d3_array &m)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr7.cpp:10
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2c.cpp:11
dvar_vector logitProp(const dvar_vector &a)
constrain probability vector as 1 and I forgot who create this first, may give credit to Punt...
Definition: qfc_est.cpp:51
double nllBinomial(const double x, const double n, const double p)
nll for binomial for one sample
Definition: qfc_est.cpp:1513
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
int rowmin(void) const
Definition: fvar.hpp:2560
Description not yet available.
Definition: fvar.hpp:2819
double norm2(const d3_array &a)
Return sum of squared elements in a.
Definition: d3arr2a.cpp:167
unsigned int size() const
Get number of elements in array.
Definition: dvector.h:209
double nllDirichlet(const dvector &p, const dvector &shape)
nll for dirichlet for one sample
Definition: qfc_est.cpp:633
int indexmin() const
Definition: fvar.hpp:2287
dvar_vector invLogitProp(const dvar_vector &p)
reverse function for LogitProp
Definition: qfc_est.cpp:82
double nllInverseGamma(const double x, const double a, const double b)
nll for inverse gamma for one sample
Definition: qfc_est.cpp:2274
double nllNegativeBinomial(const double obs, const double m, const double s)
nll for negative binomial N(m,s) for one sample, admb built in log_negbinomial_density(obs,mu,tau), in which tau=1.
Definition: qfc_est.cpp:315
Description not yet available.
Definition: df1b2fun.h:1042
double nllPoisson(const double x, const double lambda)
nll for poisson for one sample
Definition: qfc_est.cpp:2132
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
double eps
Definition: ftweak.cpp:13
int indexmax(void) const
Definition: df1b2fun.h:970
unsigned int size_count(const dvector &x)
Returns total size of elements in vector x.
Definition: dsize.cpp:17
dvariable boundp(const prevariable &x, double fmin, double fmax, const prevariable &_fpen, double s)
Compute penalty for exceeding bounds on parameter; variable ojbects.
Definition: boundfun.cpp:89
double nllMultiNomial(const dvector &obsN, const dvector &p)
nll for Multinomial for one sample
Definition: qfc_est.cpp:560
void RETURN_ARRAYS_INCREMENT(void)
Increments gradient_structure::RETURN_ARRAYS_PTR.
Definition: gradstrc.cpp:474
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
int colmin(void) const
Definition: df1b2fun.h:1089
#define M_PI
Definition: fvar.hpp:92
double nllLognormal(const double x, const double mu, const double sigma)
nll for lognormal for one sample
Definition: qfc_est.cpp:1655
double log_density_negbinomial(double x, double mu, double tau)
Log negative bionomial density; constant objects.
Definition: cnegbin.cpp:22
int colmax(void) const
Definition: df1b2fun.h:1090
double log_negbinomial_density(double x, double mu, double tau)
int rowmax(void) const
Definition: df1b2fun.h:1056
int indexmax() const
Definition: fvar.hpp:2292
double square(const double value)
Return square of value; constant object.
Definition: d3arr4.cpp:16
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
dvariable mf_upper_bound2(const dvariable &x, const double fmax, dvariable &fpen)
constrain parameter with upper threshold, if return bigger than it, then with penalty ADMB have built...
Definition: qfc_est.cpp:210
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13
double log_gamma_density(double x, double r, double mu)
Log gamma probability density function; constant objects.
Definition: cgamdens.cpp:35
double nllBeta(const double x, const double a, const double b)
nll for beta for one sample
Definition: qfc_est.cpp:885
int colmax(void) const
Definition: fvar.hpp:2556