TMB Documentation  v1.9.1
dnorm.hpp
Go to the documentation of this file.
1 // Copyright (C) 2013-2015 Kasper Kristensen
2 // License: GPL-2
3 
16 template<class Type>
17 Type dnorm(Type x, Type mean, Type sd, int give_log=0)
18 {
19  Type resid = (x - mean) / sd;
20  Type logans = -log(sqrt(2*M_PI)) - log(sd) - Type(.5) * resid * resid;
21  if(give_log) return logans; else return exp(logans);
22 }
Type dnorm(Type x, Type mean, Type sd, int give_log=0)
Probability density function of the normal distribution.
Definition: dnorm.hpp:17
#define VECTORIZE4_ttti(FUN)
Vectorize 4-argument functions.
Definition: Vectorize.hpp:105
License: GPL v2