TMB Documentation  v1.9.1
distributions_R.hpp
Go to the documentation of this file.
1 // Copyright (C) 2013-2015 Kasper Kristensen
2 // License: GPL-2
3 
11 template<class Type>
12 Type pnorm(Type q, Type mean = 0., Type sd = 1.){
13  CppAD::vector<Type> tx(1);
14  tx[0] = (q - mean) / sd;
15  return atomic::pnorm1(tx)[0];
16 }
19 
20 
23 template<class Type>
24 Type qnorm(Type p, Type mean = 0., Type sd = 1.){
25  CppAD::vector<Type> tx(1);
26  tx[0] = p;
27  return sd*atomic::qnorm1(tx)[0] + mean;
28 }
31 
32 
35 template<class Type>
36 Type pgamma(Type q, Type shape, Type scale = 1.){
37  CppAD::vector<Type> tx(4);
38  tx[0] = q/scale;
39  tx[1] = shape;
40  tx[2] = Type(0); // 0'order deriv
41  tx[3] = -lgamma(shape); // normalize
42  return atomic::D_incpl_gamma_shape(tx)[0];
43 }
45 
46 
49 template<class Type>
50 Type qgamma(Type q, Type shape, Type scale = 1.){
51  CppAD::vector<Type> tx(3);
52  tx[0] = q;
53  tx[1] = shape;
54  tx[2] = -lgamma(shape); // normalize
55  return atomic::inv_incpl_gamma(tx)[0] * scale;
56 }
58 
59 
62 template<class Type>
63 Type ppois(Type q, Type lambda){
64  CppAD::vector<Type> tx(2);
65  tx[0] = q;
66  tx[1] = lambda;
67  return atomic::ppois(tx)[0];
68 }
70 
71 
79 template<class Type>
80 Type pexp(Type x, Type rate)
81 {
82  return CppAD::CondExpGe(x,Type(0),1-exp(-rate*x),Type(0));
83 }
84 
85 // Vectorize pexp
87 
88 
93 template<class Type>
94 Type dexp(Type x, Type rate, int give_log=0)
95 {
96  if(!give_log)
97  return CppAD::CondExpGe(x,Type(0),rate*exp(-rate*x),Type(0));
98  else
99  return CppAD::CondExpGe(x,Type(0),log(rate)-rate*x,Type(-INFINITY));
100 }
101 
102 // Vectorize dexp
104 
105 
109 template <class Type>
110 Type qexp(Type p, Type rate)
111 {
112  return -log(1-p)/rate;
113 }
114 
115 // Vectorize qexp.
129 template<class Type>
130 Type pweibull(Type x, Type shape, Type scale)
131 {
132  return CppAD::CondExpGe(x,Type(0),1-exp(-pow(x/scale,shape)),Type(0));
133 }
134 
135 // Vectorize pweibull
137 
138 
144 template<class Type>
145 Type dweibull(Type x, Type shape, Type scale, int give_log=0)
146 {
147  if(!give_log)
148  return CppAD::CondExpGe(x,Type(0),shape/scale * pow(x/scale,shape-1) * exp(-pow(x/scale,shape)),Type(0));
149  else
150  return CppAD::CondExpGe(x,Type(0),log(shape) - log(scale) + (shape-1)*(log(x)-log(scale)) - pow(x/scale,shape),Type(-INFINITY));
151 }
152 
153 // Vectorize dweibull
155 
156 
162 template<class Type>
163 Type qweibull(Type p, Type shape, Type scale)
164 {
165  Type res = scale * pow( (-log(1-p)) , 1/shape );
166  res = CppAD::CondExpLt(p,Type(0),Type(0),res);
167  res = CppAD::CondExpGt(p,Type(1),Type(0),res);
168  return res;
169 }
170 
171 // Vectorize qweibull
182 template<class Type>
183 Type dbinom(Type k, Type size, Type prob, int give_log=0)
184 {
185  Type logres = lgamma(size + 1) - lgamma(k + 1) - lgamma(size - k + 1);
186  // Add 'k * log(prob)' only if k > 0
187  logres += CppAD::CondExpGt(k, Type(0), k * log(prob), Type(0) );
188  // Add '(size - k) * log(1 - prob)' only if size > k
189  logres += CppAD::CondExpGt(size, k, (size - k) * log(1 - prob), Type(0) );
190  if (!give_log) return exp(logres);
191  else return logres;
192 }
193 
194 // Vectorize dbinom
196 
197 
204 template<class Type>
205 Type dbinom_robust(Type k, Type size, Type logit_p, int give_log=0)
206 {
207  CppAD::vector<Type> tx(4);
208  tx[0] = k;
209  tx[1] = size;
210  tx[2] = logit_p;
211  tx[3] = 0;
212  Type ans = atomic::log_dbinom_robust(tx)[0]; /* without norm. constant */
213  if (size > 1) {
214  ans += lgamma(size+1.) - lgamma(k+1.) - lgamma(size-k+1.);
215  }
216  return ( give_log ? ans : exp(ans) );
217 }
219 
220 
226 template <class Type>
227 Type dbeta(Type x, Type shape1, Type shape2, int give_log)
228 {
229  Type res = exp(lgamma(shape1+shape2) - lgamma(shape1) - lgamma(shape2)) * pow(x,shape1-1) * pow(1-x,shape2-1);
230  if(!give_log)
231  return res;
232  else
233  return CppAD::CondExpEq(x,Type(0),log(res),lgamma(shape1+shape2) - lgamma(shape1) - lgamma(shape2) + (shape1-1)*log(x) + (shape2-1)*log(1-x));
234 }
235 
236 // Vectorize dbeta
238 
239 
245 template <class Type>
246 Type df(Type x, Type df1, Type df2, int give_log)
247 {
248  Type logres = lgamma((df1+df2)/2.) - lgamma(df1/2.) - lgamma(df2/2.) + df1/2.*log(Type(df1)/df2) + (df1/2.-1)*log(x) - (df1+df2)/2.*log(1+Type(df1)/df2*x);
249  if(!give_log) return exp(logres);
250  else return logres;
251 }
252 
253 //Vectorize df
255 
256 
262 template <class Type>
263 Type dlogis(Type x, Type location, Type scale, int give_log)
264 {
265  Type logres = -(x-location)/scale - log(scale) - 2*log(1+exp(-(x-location)/scale));
266  if(!give_log) return exp(logres);
267  else return logres;
268 }
269 
270 // Vectorize dlogis
272 
273 
278 template <class Type>
279 Type dsn(Type x, Type alpha, int give_log=0)
280 {
281 
282  if(!give_log) return 2 * dnorm(x,Type(0),Type(1),0) * pnorm(alpha*x);
283  else return log(2.0) + log(dnorm(x,Type(0),Type(1),0)) + log(pnorm(alpha*x));
284 }
285 
286 // Vectorize dsn
288 
289 
294 template <class Type>
295 Type dt(Type x, Type df, int give_log)
296 {
297  Type logres = lgamma((df+1)/2) - Type(1)/2*log(df*M_PI) -lgamma(df/2) - (df+1)/2*log(1+x*x/df);
298  if(!give_log) return exp(logres);
299  else return logres;
300 }
301 
302 // Vectorize dt
304 
305 
311 template <class Type>
312 Type dmultinom(vector<Type> x, vector<Type> p, int give_log=0)
313 {
314  vector<Type> xp1 = x+Type(1);
315  Type logres = lgamma(x.sum() + Type(1)) - lgamma(xp1).sum() + (x*log(p)).sum();
316  if(give_log) return logres;
317  else return exp(logres);
318 }
319 
338 template <class Type>
339 Type dSHASHo(Type x, Type mu, Type sigma, Type nu, Type tau, int give_log = 0)
340 {
341  // TODO : Replace log(x+sqrt(x^2+1)) by a better approximation for asinh(x).
342 
343  Type z = (x-mu)/sigma;
344  Type c = cosh(tau*log(z+sqrt(z*z+1))-nu);
345  Type r = sinh(tau*log(z+sqrt(z*z+1))-nu);
346  Type logres = -log(sigma) + log(tau) -0.5*log(2*M_PI) -0.5*log(1+(z*z)) +log(c) -0.5*(r*r);
347 
348  if(!give_log) return exp(logres);
349  else return logres;
350 }
351 
352 // Vectorize dSHASHo
354 
355 
367 template <class Type>
368 Type pSHASHo(Type q,Type mu,Type sigma,Type nu,Type tau,int give_log=0)
369 {
370  // TODO : Replace log(x+sqrt(x^2+1)) by a better approximation for asinh(x).
371 
372  Type z = (q-mu)/sigma;
373  Type r = sinh(tau * log(z+sqrt(z*z+1)) - nu);
374  Type p = pnorm(r);
375 
376  if (!give_log) return p;
377  else return log(p);
378 }
379 
380 // Vectorize pSHASHo
382 
383 
395 template <class Type>
396 Type qSHASHo(Type p, Type mu, Type sigma, Type nu, Type tau, int log_p = 0)
397 {
398  // TODO : Replace log(x+sqrt(x^2+1)) by a better approximation for asinh(x).
399 
400  if(!log_p) return mu + sigma*sinh((1/tau)* log(qnorm(p)+sqrt(qnorm(p)*qnorm(p)+1)) + (nu/tau));
401  else return mu + sigma*sinh((1/tau)*log(qnorm(exp(p))+sqrt(qnorm(exp(p))*qnorm(exp(p))+1))+(nu/tau));
402 }
403 
404 // Vectorize qSHASHo
406 
407 
416 template <class Type>
417 Type norm2SHASHo(Type x, Type mu, Type sigma, Type nu, Type tau, int log_p = 0)
418 {
419 
420  return qSHASHo(pnorm(x),mu,sigma,nu,tau,log_p);
421 }
422 
423 // Vectorize norm2SHASHo
432 template<class Type>
433 Type pbeta(Type q, Type shape1, Type shape2){
434  CppAD::vector<Type> tx(4);
435  tx[0] = q;
436  tx[1] = shape1;
437  tx[2] = shape2;
438  tx[3] = 0; // order
439  Type ans = atomic::pbeta(tx)[0];
440  return ans;
441 }
443 
444 
449 template<class Type>
450 Type qbeta(Type p, Type shape1, Type shape2){
451  CppAD::vector<Type> tx(3);
452  tx[0] = p;
453  tx[1] = shape1;
454  tx[2] = shape2;
455  Type ans = atomic::qbeta(tx)[0];
456  return ans;
457 }
459 
460 
464 template<class Type>
465 Type besselK(Type x, Type nu){
466  Type ans;
467  if(CppAD::Variable(nu)) {
468  CppAD::vector<Type> tx(3);
469  tx[0] = x;
470  tx[1] = nu;
471  tx[2] = 0;
472  ans = atomic::bessel_k(tx)[0];
473  } else {
474  CppAD::vector<Type> tx(2);
475  tx[0] = x;
476  tx[1] = nu;
477  ans = atomic::bessel_k_10(tx)[0];
478  }
479  return ans;
480 }
482 
483 
487 template<class Type>
488 Type besselI(Type x, Type nu){
489  Type ans;
490  if(CppAD::Variable(nu)) {
491  CppAD::vector<Type> tx(3);
492  tx[0] = x;
493  tx[1] = nu;
494  tx[2] = 0;
495  ans = atomic::bessel_i(tx)[0];
496  } else {
497  CppAD::vector<Type> tx(2);
498  tx[0] = x;
499  tx[1] = nu;
500  ans = atomic::bessel_i_10(tx)[0];
501  }
502  return ans;
503 }
505 
506 
510 template<class Type>
511 Type besselJ(Type x, Type nu){
512  CppAD::vector<Type> tx(3);
513  tx[0] = x;
514  tx[1] = nu;
515  tx[2] = 0;
516  Type ans = atomic::bessel_j(tx)[0];
517  return ans;
518 }
520 
521 
525 template<class Type>
526 Type besselY(Type x, Type nu){
527  CppAD::vector<Type> tx(3);
528  tx[0] = x;
529  tx[1] = nu;
530  tx[2] = 0;
531  Type ans = atomic::bessel_y(tx)[0];
532  return ans;
533 }
535 
536 
550 template<class Type>
551 Type dtweedie(Type y, Type mu, Type phi, Type p, int give_log = 0) {
552  Type p1 = p - 1.0, p2 = 2.0 - p;
553  Type ans = -pow(mu, p2) / (phi * p2); // log(prob(y=0))
554  if (y > 0) {
555  CppAD::vector<Type> tx(4);
556  tx[0] = y;
557  tx[1] = phi;
558  tx[2] = p;
559  tx[3] = 0;
560  ans += atomic::tweedie_logW(tx)[0];
561  ans += -y / (phi * p1 * pow(mu, p1)) - log(y);
562  }
563  return ( give_log ? ans : exp(ans) );
564 }
566 
567 
568 
577 template<class Type>
578 Type compois_calc_logZ(Type loglambda, Type nu) {
579  CppAD::vector<Type> tx(3);
580  tx[0] = loglambda;
581  tx[1] = nu;
582  tx[2] = 0;
583  return atomic::compois_calc_logZ(tx)[0];
584 }
586 
587 
595 template<class Type>
596 Type compois_calc_loglambda(Type logmean, Type nu) {
597  CppAD::vector<Type> tx(3);
598  tx[0] = logmean;
599  tx[1] = nu;
600  tx[2] = 0;
601  return atomic::compois_calc_loglambda(tx)[0];
602 }
604 
605 
618 template<class T1, class T2, class T3>
619 T1 dcompois(T1 x, T2 mode, T3 nu, int give_log = 0) {
620  T2 loglambda = nu * log(mode);
621  T1 ans = x * loglambda - nu * lfactorial(x);
622  ans -= compois_calc_logZ(loglambda, nu);
623  return ( give_log ? ans : exp(ans) );
624 }
625 
638 template<class T1, class T2, class T3>
639 T1 dcompois2(T1 x, T2 mean, T3 nu, int give_log = 0) {
640  T2 logmean = log(mean);
641  T2 loglambda = compois_calc_loglambda(logmean, nu);
642  T1 ans = x * loglambda - nu * lfactorial(x);
643  ans -= compois_calc_logZ(loglambda, nu);
644  return ( give_log ? ans : exp(ans) );
645 }
646 
647 /********************************************************************/
648 /* SIMULATON CODE */
649 /********************************************************************/
650 
651 extern "C" {
652  double Rf_rnorm(double mu, double sigma);
653 }
655 template<class Type>
656 Type rnorm(Type mu, Type sigma)
657 {
658  return Rf_rnorm(asDouble(mu), asDouble(sigma));
659 }
662 
663 extern "C" {
664  double Rf_rpois(double mu);
665 }
667 template<class Type>
668 Type rpois(Type mu)
669 {
670  return Rf_rpois(asDouble(mu));
671 }
674 
675 extern "C" {
676  double Rf_runif(double a, double b);
677 }
679 template<class Type>
680 Type runif(Type a, Type b)
681 {
682  return Rf_runif(asDouble(a), asDouble(b));
683 }
686 
687 extern "C" {
688  double Rf_rbinom(double size, double prob);
689 }
691 template<class Type>
692 Type rbinom(Type size, Type prob)
693 {
694  return Rf_rbinom(asDouble(size), asDouble(prob));
695 }
698 
699 extern "C" {
700  double Rf_rgamma(double shape, double scale);
701 }
703 template<class Type>
704 Type rgamma(Type shape, Type scale)
705 {
706  return Rf_rgamma(asDouble(shape), asDouble(scale));
707 }
710 
711 extern "C" {
712  double Rf_rexp(double rate);
713 }
715 template<class Type>
716 Type rexp(Type rate)
717 {
718  return Rf_rexp(asDouble(rate));
719 }
720 
723 
724 extern "C" {
725  double Rf_rbeta(double shape1, double shape2);
726 }
728 template<class Type>
729 Type rbeta(Type shape1, Type shape2)
730 {
731  return Rf_rbeta(asDouble(shape1), asDouble(shape2));
732 }
733 
736 
737 extern "C" {
738  double Rf_rf(double df1, double df2);
739 }
741 template<class Type>
742 Type rf(Type df1, Type df2)
743 {
744  return Rf_rf(asDouble(df1), asDouble(df2));
745 }
746 
749 
750 extern "C" {
751  double Rf_rlogis(double location, double scale);
752 }
754 template<class Type>
755 Type rlogis(Type location, Type scale)
756 {
757  return Rf_rlogis(asDouble(location), asDouble(scale));
758 }
759 
762 
763 extern "C" {
764  double Rf_rt(double df);
765 }
767 template<class Type>
768 Type rt(Type df)
769 {
770  return Rf_rt(asDouble(df));
771 }
772 
775 
776 extern "C" {
777  double Rf_rweibull(double shape, double scale);
778 }
780 template<class Type>
781 Type rweibull(Type shape, Type scale)
782 {
783  return Rf_rweibull(asDouble(shape), asDouble(scale));
784 }
785 
788 
789 
790 template<class Type>
791 Type rcompois(Type mode, Type nu)
792 {
793  Type loglambda = nu * log(mode);
794  return atomic::compois_utils::simulate(asDouble(loglambda), asDouble(nu));
795 }
798 
799 
800 template<class Type>
801 Type rcompois2(Type mean, Type nu)
802 {
803  Type logmean = log(mean);
804  Type loglambda = compois_calc_loglambda(logmean, nu);
805  return atomic::compois_utils::simulate(asDouble(loglambda), asDouble(nu));
806 }
808 
809 // Note: Vectorize manually to avoid many identical calls to
810 // 'calc_loglambda'.
811 template<class Type>
812 vector<Type> rcompois2(int n, Type mean, Type nu)
813 {
814  Type logmean = log(mean);
815  Type loglambda = compois_calc_loglambda(logmean, nu);
816  Type mode = exp(loglambda / nu);
817  return rcompois(n, mode, nu);
818 }
819 
821 template<class Type>
822 Type rtweedie(Type mu, Type phi, Type p) {
823  // Copied from R function tweedie::rtweedie
824  Type lambda = pow(mu, 2. - p) / (phi * (2. - p));
825  Type alpha = (2. - p) / (1. - p);
826  Type gam = phi * (p - 1.) * pow(mu, p - 1.);
827  Type N = rpois(lambda);
828  Type ans = rgamma( -alpha * N /* shape */, gam /* scale */);
829  return ans;
830 }
#define VECTORIZE2_tt(FUN)
Vectorize 2-argument functions.
Definition: Vectorize.hpp:71
Type rexp(Type rate)
Simulate from an exponential distribution.
Type rcompois2(Type mean, Type nu)
Simulate from a Conway-Maxwell-Poisson distribution.
Type qbeta(Type p, Type shape1, Type shape2)
Quantile function of the beta distribution (following R argument convention).
Vector class used by TMB.
Definition: vector.hpp:17
Type pbeta(Type q, Type shape1, Type shape2)
Distribution function of the beta distribution (following R argument convention). ...
CppAD::vector< Type > pnorm1(CppAD::vector< Type > x)
Atomic version of standard normal distribution function. Derivative is known to be &#39;dnorm1&#39;...
Type ppois(Type q, Type lambda)
Distribution function of the poisson distribution (following R argument convention).
CppAD::vector< Type > inv_incpl_gamma(CppAD::vector< Type > x)
Atomic version of inverse of scaled incomplete gamma function. Given find such that where the 3 in...
Type pSHASHo(Type q, Type mu, Type sigma, Type nu, Type tau, int give_log=0)
Cumulative distribution function of the sinh-asinh distribution.
Type rcompois(Type mode, Type nu)
Simulate from a Conway-Maxwell-Poisson distribution.
#define VECTORIZE2_n(FUN)
Add the &#39;n&#39; integer argument to a simulation method with two arguments.
Definition: Vectorize.hpp:154
#define VECTORIZE3_n(FUN)
Add the &#39;n&#39; integer argument to a simulation method with three arguments.
Definition: Vectorize.hpp:164
Type dSHASHo(Type x, Type mu, Type sigma, Type nu, Type tau, int give_log=0)
Probability density function of the sinh-asinh distribution.
Type qnorm(Type p, Type mean=0., Type sd=1.)
Quantile function of the normal distribution (following R argument convention).
#define VECTORIZE1_t(FUN)
Vectorize 1-argument functions.
Definition: Vectorize.hpp:63
Type rtweedie(Type mu, Type phi, Type p)
Simulate from tweedie distribution.
Type qgamma(Type q, Type shape, Type scale=1.)
Quantile function of the gamma distribution (following R argument convention).
Type dbeta(Type x, Type shape1, Type shape2, int give_log)
Probability density function of the beta distribution.
CppAD::vector< Type > bessel_k_10(CppAD::vector< Type > x)
Atomic version of . Valid parameter range: .
Type df(Type x, Type df1, Type df2, int give_log)
Probability density function of the Fisher distribution.
Type dbinom(Type k, Type size, Type prob, int give_log=0)
Probability mass function of the binomial distribution.
Type dlogis(Type x, Type location, Type scale, int give_log)
Probability density function of the logistic distribution.
Type rlogis(Type location, Type scale)
Simulate from a logistic distribution.
Type dtweedie(Type y, Type mu, Type phi, Type p, int give_log=0)
dtweedie function (same as dtweedie.series from R package &#39;tweedie&#39;).
Type rf(Type df1, Type df2)
Simulate from an F distribution.
Type dnorm(Type x, Type mean, Type sd, int give_log=0)
Probability density function of the normal distribution.
Definition: dnorm.hpp:17
Type lfactorial(Type x)
Logarithm of factorial function (following R argument convention).
Definition: lgamma.hpp:24
Type besselY(Type x, Type nu)
besselY function (same as besselY from R).
Type dmultinom(vector< Type > x, vector< Type > p, int give_log=0)
Probability mass function of the multinomial distribution.
Type besselI(Type x, Type nu)
besselI function (same as besselI from R).
Type dexp(Type x, Type rate, int give_log=0)
Probability density function of the exponential distribution.
Type lgamma(Type x)
Logarithm of gamma function (following R argument convention).
Definition: lgamma.hpp:12
#define VECTORIZE6_ttttti(FUN)
Vectorize 6-argument functions.
Definition: Vectorize.hpp:133
#define VECTORIZE4_ttti(FUN)
Vectorize 4-argument functions.
Definition: Vectorize.hpp:105
Type dbinom_robust(Type k, Type size, Type logit_p, int give_log=0)
Density of binomial distribution parameterized via logit(prob)
Type rweibull(Type shape, Type scale)
Simulate from a Weibull distribution.
#define VECTORIZE5_tttti(FUN)
Vectorize 5-argument functions.
Definition: Vectorize.hpp:119
Type norm2SHASHo(Type x, Type mu, Type sigma, Type nu, Type tau, int log_p=0)
Transforms a normal variable into a sinh-asinh variable.
Type pweibull(Type x, Type shape, Type scale)
Cumulative distribution function of the Weibull distribution.
Type qexp(Type p, Type rate)
Inverse cumulative distribution function of the exponential distribution.
Type dt(Type x, Type df, int give_log)
Probability density function of the Student t-distribution.
Type pexp(Type x, Type rate)
Cumulative distribution function of the exponential distribution.
CppAD::vector< Type > bessel_i_10(CppAD::vector< Type > x)
Atomic version of . Valid parameter range: .
Type besselK(Type x, Type nu)
besselK function (same as besselK from R).
T1 dcompois(T1 x, T2 mode, T3 nu, int give_log=0)
Conway-Maxwell-Poisson. Calculate density.
Type compois_calc_loglambda(Type logmean, Type nu)
Conway-Maxwell-Poisson. Calculate log(lambda) from log(mean).
#define VECTORIZE1_n(FUN)
Add the &#39;n&#39; integer argument to a simulation method with one argument.
Definition: Vectorize.hpp:144
Type rpois(Type mu)
Simulate from a Poisson distribution.
Type rt(Type df)
Simulate from a Student&#39;s t distribution.
CppAD::vector< Type > qnorm1(CppAD::vector< Type > x)
Atomic version of standard normal quantile function. Derivative is expressed through &#39;dnorm1&#39;...
Type dsn(Type x, Type alpha, int give_log=0)
Probability density function of the skew-normal distribution.
CppAD::vector< Type > D_incpl_gamma_shape(CppAD::vector< Type > x)
Atomic version of scaled incomplete gamma function differentiated to any order wrt. shape parameter where the 4 input parameters are passed as a vector . Note that the normalized incomplete gamma function is obtained as the special case and . Valid parameter range: .
Type rgamma(Type shape, Type scale)
Simulate from a gamma distribution.
CppAD::vector< Type > ppois(CppAD::vector< Type > x)
Atomic version of poisson cdf . Valid parameter range: .
Type dweibull(Type x, Type shape, Type scale, int give_log=0)
Probability density function of the Weibull distribution.
Type sum(Vector< Type > x)
Definition: convenience.hpp:33
Type rbinom(Type size, Type prob)
Simulate from a binomial distribution.
Type rbeta(Type shape1, Type shape2)
Simulate from a beta distribution.
Type rnorm(Type mu, Type sigma)
Simulate from a normal distribution.
Type pnorm(Type q, Type mean=0., Type sd=1.)
Distribution function of the normal distribution (following R argument convention).
Type qweibull(Type p, Type shape, Type scale)
Inverse cumulative distribution function of the Weibull distribution.
Type besselJ(Type x, Type nu)
besselJ function (same as besselJ from R).
Type runif(Type a, Type b)
Simulate from a uniform distribution.
#define VECTORIZE3_tti(FUN)
Vectorize 3-argument functions.
Definition: Vectorize.hpp:81
Type compois_calc_logZ(Type loglambda, Type nu)
Conway-Maxwell-Poisson log normalizing constant.
T1 dcompois2(T1 x, T2 mean, T3 nu, int give_log=0)
Conway-Maxwell-Poisson. Calculate density parameterized via the mean.
#define VECTORIZE3_ttt(FUN)
Vectorize 3-argument functions.
Definition: Vectorize.hpp:91
Type qSHASHo(Type p, Type mu, Type sigma, Type nu, Type tau, int log_p=0)
Quantile function of the sinh-asinh distribution.
Type pgamma(Type q, Type shape, Type scale=1.)
Distribution function of the gamma distribution (following R argument convention).
License: GPL v2