computeH: computeH

Description Usage Arguments Details Value Examples

View source: R/computeH.R

Description

computeH computes matrix, sumH, where sumH[k,j] = Sum over t (1->T-1) H_k,j(t)

Usage

1
computeH(alpha, beta, X, trans, u, sig)

Arguments

alpha

a matrix, alpha, from Forward Algorithm

beta

a matrix, beta, from Backward Algorithm

X

a vector of observed states

trans

a matrix of transition probability

u

a vector of means of Normal distribution for each state (emission probability)

sig

a vector of standard deviations of Normal distribution for each state (emission probability)

Details

H_k,j(t) = P(Z[t]=k , Z[t+1]=j | whole X = x). We omitted the normalising constant 1/P(whole X = x)).

Value

A matrix, sumH, where sumH[k,j] = Sum over t (1->T-1) P(Z[t]=k , Z[t+1]=j | whole X = x)

Examples

1
2
3
4
5
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)
computeH(alpha, beta, df$X[,1], df$trans, df$u, df$sig)

jiangrongo/HMM documentation built on May 19, 2019, 9:38 p.m.