R/computeL.R

Defines functions computeL

Documented in computeL

#' computeL
#'
#' \code{computeL} computes matrix, L, where L[k,t] = P(Z[t]=k | whole X = x)
#'
#' We only calculate P(Z[t]=k , whole X = x)= alpha[k,t] * beta[k,t]. While the true matrix, L, needs to be normalised by a constant 1/P(whole X = x))
#'
#' @export
#' @param alpha a matrix, alpha, from Forward Algorithm
#' @param beta  a matrix, beta, from Backward Algorithm
#' @return      A matrix, L, where L[k,t] = P(Z[t]=k | whole X = x).
#'
#' @examples
#' set.seed(1221)
#' df <- generateHMM(num=2,n=10)
#' alpha <- forwardAlg(df$X[,1], df$trans, df$u, df$sig)
#' beta <- backwardAlg(df$X[,1], df$trans, df$u, df$sig)
#' L <- computeL(alpha, beta)

computeL <- function(alpha, beta){
  return(alpha * beta)
}
jiangrongo/HMM documentation built on May 19, 2019, 9:38 p.m.