Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ log_mix() [12/12]

template<typename T_theta , typename T_lambda1 , typename T_lambda2 , require_any_var_t< T_theta, T_lambda1, T_lambda2 > * = nullptr>
return_type_t< T_theta, T_lambda1, T_lambda2 > stan::math::log_mix ( const T_theta &  theta,
const T_lambda1 &  lambda1,
const T_lambda2 &  lambda2 
)
inline

Return the log mixture density with specified mixing proportion and log densities and its derivative at each.

\[ \mbox{log\_mix}(\theta, \lambda_1, \lambda_2) = \log \left( \theta \exp(\lambda_1) + (1 - \theta) \exp(\lambda_2) \right). \]

\[ \frac{\partial}{\partial \theta} \mbox{log\_mix}(\theta, \lambda_1, \lambda_2) = \dfrac{\exp(\lambda_1) - \exp(\lambda_2)} {\left( \theta \exp(\lambda_1) + (1 - \theta) \exp(\lambda_2) \right)} \]

\[ \frac{\partial}{\partial \lambda_1} \mbox{log\_mix}(\theta, \lambda_1, \lambda_2) = \dfrac{\theta \exp(\lambda_1)} {\left( \theta \exp(\lambda_1) + (1 - \theta) \exp(\lambda_2) \right)} \]

\[ \frac{\partial}{\partial \lambda_2} \mbox{log\_mix}(\theta, \lambda_1, \lambda_2) = \dfrac{\theta \exp(\lambda_2)} {\left( \theta \exp(\lambda_1) + (1 - \theta) \exp(\lambda_2) \right)} \]

Template Parameters
T_thetatheta scalar type.
T_lambda1lambda1 scalar type.
T_lambda2lambda2 scalar type.
Parameters
[in]thetamixing proportion in [0, 1].
[in]lambda1first log density.
[in]lambda2second log density.
Returns
log mixture of densities in specified proportion

Definition at line 78 of file log_mix.hpp.