% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Viterbi.R
\name{Viterbi}
\alias{Viterbi}
\title{Viterbi Algorithm for HMM}
\usage{
Viterbi(Y, T_mat, O, pi0)
}
\arguments{
\item{Y}{Integer vector of observations (values in 1:N)}

\item{T_mat}{Transition matrix (K x K), \code{T_mat[i,j] = P(X_t=j | X_{t-1}=i)}}

\item{O}{Emission matrix (K x N), \code{O[i,j] = P(Y_t=j | X_t=i)}}

\item{pi0}{Initial state distribution (length K)}
}
\value{
A list with components:
  \describe{
    \item{path}{Integer vector of most likely states (length T_len)}
    \item{loglik}{Log-likelihood of the best path}
  }
}
\description{
Finds the most likely state sequence given the observations
using the Viterbi algorithm (log-space).
}
