Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
log1m_inv_logit.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__FUNCTIONS__LOG1M_INV_LOGIT_HPP
2 #define STAN__MATH__FUNCTIONS__LOG1M_INV_LOGIT_HPP
3 
4 #include <boost/math/tools/promotion.hpp>
5 
6 namespace stan {
7  namespace math {
8 
34  template <typename T>
35  inline typename boost::math::tools::promote_args<T>::type
36  log1m_inv_logit(const T u) {
37  using std::exp;
38  if (u > 0.0)
39  return -u - log1p(exp(-u)); // prevent underflow
40  return -log1p(exp(u));
41  }
42 
43  }
44 }
45 
46 #endif
boost::math::tools::promote_args< T >::type log1p(const T x)
Return the natural logarithm of one plus the specified value.
Definition: log1p.hpp:39
Eigen::Matrix< T, Rows, Cols > exp(const Eigen::Matrix< T, Rows, Cols > &m)
Return the element-wise exponentiation of the matrix or vector.
Definition: exp.hpp:18
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:16
boost::math::tools::promote_args< T >::type log1m_inv_logit(const T u)
Returns the natural logarithm of 1 minus the inverse logit of the specified argument.

     [ Stan Home Page ] © 2011–2014, Stan Development Team.