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

◆ hmm_hidden_state_prob()

template<typename T_omega , typename T_Gamma , typename T_rho , require_all_eigen_t< T_omega, T_Gamma > * = nullptr, require_eigen_col_vector_t< T_rho > * = nullptr>
Eigen::MatrixXd stan::math::hmm_hidden_state_prob ( const T_omega &  log_omegas,
const T_Gamma &  Gamma,
const T_rho &  rho 
)
inline

For a hidden Markov model with observation y, hidden state x, and parameters theta, compute the marginal probability vector for each x, given y and theta, p(x_i | y, theta).

In this setting, the hidden states are discrete and take values over the finite space {1, ..., K}. Hence for each hidden variable x, we compute a simplex with K elements. The final result is stored in a K by N matrix, where N is the length of x. log_omegas is a matrix of observational densities, where the (i, j)th entry corresponds to the density of the ith observation, y_i, given x_i = j. The transition matrix Gamma is such that the (i, j)th entry is the probability that x_n = j given x_{n - 1} = i. The rows of Gamma are simplexes. This function cannot be used to reconstruct the marginal distributon of a state sequence given parameters and an observation sequence, p(x | y, theta), because it only computes marginals on a state-by-state basis.

Template Parameters
T_omegatype of the log likelihood matrix
T_Gammatype of the transition matrix
T_rhotype of the initial guess vector
Parameters
[in]log_omegaslog matrix of observational densities
[in]Gammatransition density between hidden states
[in]rhoinitial state
Returns
the posterior probability for each latent state
Exceptions
`std::invalid_argument`if Gamma is not square or if the size of rho is not the number of rows of log_omegas
`std::domain_error`if rho is not a simplex and of the rows of Gamma are not a simplex

Definition at line 48 of file hmm_hidden_state_prob.hpp.