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

◆ log_mix() [1/12]

template<typename T >
fvar< T > stan::math::log_mix ( const fvar< T > &  theta,
const fvar< T > &  lambda1,
const fvar< T > &  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
Tinner type of the fvar
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 98 of file log_mix.hpp.