All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
log_mix.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_SCAL_FUN_LOG_MIX_HPP
#define STAN_MATH_PRIM_SCAL_FUN_LOG_MIX_HPP
#include <stan/math/prim/scal/err/check_bounded.hpp>
#include <stan/math/prim/scal/err/check_not_nan.hpp>
#include <stan/math/prim/scal/fun/log_sum_exp.hpp>
#include <stan/math/prim/scal/fun/log1m.hpp>
#include <cmath>
namespace stan {
namespace math {
double log_mix(double theta,
double lambda1,
double lambda2) {
using std::log;
stan::math::check_not_nan("log_mix", "lambda1", lambda1);
stan::math::check_not_nan("log_mix", "lambda2", lambda2);
stan::math::check_bounded("log_mix", "theta", theta, 0, 1);
return log_sum_exp(log(theta) + lambda1,
log1m(theta) + lambda2);
}
}
}
#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::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:116
stan::math::log1m
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:16

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