| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/scal/err/check_bounded.hpp>
5 #include <stan/math/prim/scal/err/check_not_nan.hpp>
6 #include <stan/math/prim/scal/fun/log_sum_exp.hpp>
7 #include <stan/math/prim/scal/fun/log1m.hpp>
8 #include <cmath>
9
10 namespace stan {
11 namespace math {
12
45 inline double log_mix(double theta,
46 double lambda1,
47 double lambda2) {
48 using std::log;
49 check_not_nan("log_mix", "lambda1", lambda1);
50 check_not_nan("log_mix", "lambda2", lambda2);
51 check_bounded("log_mix", "theta", theta, 0, 1);
52 return log_sum_exp(log(theta) + lambda1,
53 log1m(theta) + lambda2);
54 }
55
56 }
57 }
58 #endif
check_not_nan.hpp
stan::math::check_not_nan
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
Definition: check_not_nan.hpp:60
stan
Definition: log_sum_exp.hpp:8
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:14
stan::math::check_bounded
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.
Definition: check_bounded.hpp:95
stan::math::log_sum_exp
fvar< T > log_sum_exp(const std::vector< fvar< T > > &v)
Definition: log_sum_exp.hpp:13
log_sum_exp.hpp
log1m.hpp
check_bounded.hpp
stan::math::log_mix
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:116
stan::math::log1m
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:15

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