% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Forward.R
\name{Forward}
\alias{Forward}
\title{Forward Algorithm for HMM}
\usage{
Forward(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{alpha}{Matrix (K x T_len) of scaled forward probabilities}
    \item{loglik}{Log-likelihood of the observation sequence}
    \item{scale}{Vector of scaling factors (length T_len)}
  }
}
\description{
Computes forward probabilities \eqn{\alpha_t(i) = P(Y_1, \ldots, Y_t, X_t = i)}
with log-scaling to avoid underflow.
}
