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

◆ log_mix() [11/12]

template<typename T_theta , typename T_lam , require_vector_t< T_lam > * = nullptr>
return_type_t< T_theta, std::vector< T_lam > > stan::math::log_mix ( const T_theta &  theta,
const std::vector< T_lam > &  lambda 
)

Return the log mixture density given specified mixing proportions and array of log density vectors.

\[ \frac{\partial }{\partial p_x}\left[ \log\left(\exp^{\log\left(p_1\right)+d_1}+\cdot\cdot\cdot+ \exp^{\log\left(p_n\right)+d_n}\right)+ \log\left(\exp^{\log\left(p_1\right)+f_1}+\cdot\cdot\cdot+ \exp^{\log\left(p_n\right)+f_n}\right)\right] =\frac{e^{d_x}}{e^{d_1}p_1+\cdot\cdot\cdot+e^{d_m}p_m}+ \frac{e^{f_x}}{e^{f_1}p_1+\cdot\cdot\cdot+e^{f_m}p_m} \]

\[ \frac{\partial }{\partial d_x}\left[ \log\left(\exp^{\log\left(p_1\right)+d_1}+\cdot\cdot\cdot+ \exp^{\log\left(p_n\right)+d_n}\right) +\log\left(\exp^{\log\left(p_1\right)+f_1}+\cdot\cdot\cdot+ \exp^{\log\left(p_n\right)+f_n}\right)\right] =\frac{e^{d_x}p_x}{e^{d_1}p_1+\cdot\cdot\cdot+e^{d_m}p_m} \]

Template Parameters
T_thetaType of theta. This can be a scalar, std vector or row/column vector
T_lamType of vector in std vector lambda. This can be std vector or row/column vector.
Parameters
thetastd/row/col vector of mixing proportions in [0, 1].
lambdastd vector containing std/row/col vectors of log densities.
Returns
log mixture of densities in specified proportion

Definition at line 144 of file log_mix.hpp.