For context a hidden Markov model is specified through a joint probability density function over observations y_{1:N} and discrete hidden states z_{1:N} with the conditional decomposition

\pi(y_{1:N}, z_{1:N} \mid \theta) = \pi(y_{1:N} \mid z_{1:N}, \theta) \, \pi(z_{1:N} \mid \theta).

The particular conditional structure \pi(y_{1:N} \mid z_{1:N}, \theta) and$ \pi(z_{1:N}$ allows us to explicitly integrate out the discrete hidden states to gives the marginal probability density function

\pi(y_{1:N} \mid \theta) = \sum_{z_{1:N}} \pi(y_{1:N}, z_{1:N} \mid \theta).

It is this marginal probability density function that has been implemented.

The problem with calling this marginal density `hmm_lpdf`

or similar is that most applied fields consider the joint density \pi(y_{1:N}, z_{1:N} \mid \theta) to be hidden Markov model itself. This is supported by the many software packages that support hidden Markov model inference that work with both the observed data and the hidden states.

The preliminary name `hmm_marginal_lpdf`

was chosen to explicate the automatic marginalization of the hidden states relative to other packages that work with the full joint model.

Others have complained about “marginal” being ambiguous, but in this context there are only two natural marginals,

\pi(y_{1:N} \mid \theta) = \sum_{z_{1:N}} \pi(y_{1:N}, z_{1:N} \mid \theta)

and

\pi(z_{1:N} \mid \theta) = \int \mathrm{d} y_{1:N} \, \pi(y_{1:N}, z_{1:N} \mid \theta),

with the second being both a trivial marginal and not relevant to the inferential context where we condition on observed data. Consequently \pi(y_{1:N} \mid \theta) is the only nontrivial, natural marginal density function. Only one marginal being natural is common in other models as well, for example “collapsed” latent Dirichlet allocation models where the “collapsed” refers by convention to only the discrete parameters without any ambiguity.