Stan Math Library  2.10.0
reverse mode automatic differentiation
log_mix.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_LOG_MIX_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_LOG_MIX_HPP
3 
8 #include <cmath>
9 
10 namespace stan {
11 
12  namespace math {
13 
46  double log_mix(double theta,
47  double lambda1,
48  double lambda2) {
49  using std::log;
50  stan::math::check_not_nan("log_mix", "lambda1", lambda1);
51  stan::math::check_not_nan("log_mix", "lambda2", lambda2);
52  stan::math::check_bounded("log_mix", "theta", theta, 0, 1);
53  return log_sum_exp(log(theta) + lambda1,
54  log1m(theta) + lambda2);
55  }
56 
57  }
58 
59 }
60 
61 #endif
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
bool check_bounded(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
Return true if the value is between the low and high values, inclusively.
fvar< T > log_sum_exp(const std::vector< fvar< T > > &v)
Definition: log_sum_exp.hpp:14
fvar< T > log_mix(const fvar< T > &theta, const fvar< T > &lambda1, const fvar< T > &lambda2)
Return the log mixture density with specified mixing proportion and log densities and its derivative ...
Definition: log_mix.hpp:117
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:16

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