Stan Math Library: stan/math/prim/scal/fun/log_mix.hpp Source File

| Stan Math Library 2.10.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
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
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:63
stan
Definition: log_sum_exp.hpp:8
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
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:14
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:117
stan::math::log1m
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:16

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