For a Hidden Markov Model with observation y, hidden state x, and parameters theta, return the log marginal density, log p(y | theta).
In this setting, the hidden states are discrete and take values over the finite space {1, ..., K}. The marginal lpdf is obtained via a forward pass, and the derivative is calculated with an adjoint method, e.g (Betancourt, Margossian, & Leos-Barajas, 2020). log_omegas is a matrix of observational densities, where the (i, j)th entry corresponds to the density of the jth observation, y_j, given x_j = i. 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.
- Template Parameters
-
T_omega | type of the log likelihood matrix |
T_Gamma | type of the transition matrix |
T_rho | type of the initial guess vector |
- Parameters
-
[in] | log_omegas | log matrix of observational densities. |
[in] | Gamma | transition density between hidden states. |
[in] | rho | initial state |
- Returns
- log marginal density.
- Exceptions
-
`std::invalid_argument` | if Gamma is not square, when we have at least one transition, 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 (when there is at least one transition). |
Definition at line 76 of file hmm_marginal.hpp.