SCM

SCM Repository

[depmix] Diff of /trunk/R/viterbi.R
ViewVC logotype

Diff of /trunk/R/viterbi.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 92, Thu Mar 20 11:05:16 2008 UTC revision 93, Thu Mar 20 11:32:06 2008 UTC
# Line 1  Line 1 
1  viterbi <- function(hmm) {  viterbi <- function(object) {
2      # returns the most likely state sequence      # returns the most likely state sequence
3      nt <- sum(hmm@ntimes)      nt <- sum(object@ntimes)
4      lt <- length(hmm@ntimes)      lt <- length(object@ntimes)
5                  et <- cumsum(hmm@ntimes)                  et <- cumsum(object@ntimes)
6                  bt <- c(1,et[-lt]+1)                  bt <- c(1,et[-lt]+1)
7    
8      ns <- hmm@nstates      ns <- object@nstates
9    
10      delta <- psi <- matrix(nrow=nt,ncol=ns)      delta <- psi <- matrix(nrow=nt,ncol=ns)
11      state <- vector(length=nt)      state <- vector(length=nt)
12    
13      prior <- exp(logDens(hmm@initModel))      prior <- object@init
14    
15      A <- hmm@trans      A <- object@trDens
16      B <- apply(hmm@logdens,c(1,3),sum)      B <- apply(log(object@dens),c(1,3),sum)
17    
18      for(case in 1:lt) {      for(case in 1:lt) {
19      # initialization      # initialization

Legend:
Removed from v.92  
changed lines
  Added in v.93

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge