# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1217813371 25200
# Node ID d1058cb7f1393ba458f1eedc44d9833b1939afa4
# Parent 80bce2448195e008b6510a04f879d54a06238f76
trac #3726  finished first HMM code.
diff r 80bce2448195 r d1058cb7f139 sage/stats/hmm/chmm.pyx
a

b

cdef class GaussianHiddenMarkovModel(Con 
596  596  exception on error 
597  597  
598  598  EXAMPLES: 
 599  We train a very simple model: 
 600  sage: m = hmm.GaussianHiddenMarkovModel([[1]], [(0,1)], [1]) 
 601  sage: m.baum_welch([1,1,1,1]) 
599  602  
600   NOTE: Training for models including silent states is not yet supported. 
601   
602   REFERENCES: 
603   Rabiner, L.R.: "`A Tutorial on Hidden Markov Models and Selected 
604   Applications in Speech Recognition"', Proceedings of the IEEE, 
605   77, no 2, 1989, pp 257285. 
 603  Notice that after training the mean in the emission parameters changes 
 604  form 0 to 1. 
 605  sage: m 
 606  Gaussian Hidden Markov Model with 1 States 
 607  Transition matrix: 
 608  [1.0] 
 609  Emission parameters: 
 610  [(1.0, 0.0001)] 
 611  Initial probabilities: [1.0] 
606  612  """ 
607  613  cdef ghmm_cmodel_baum_welch_context cs 
608  614  
609  615  cs.smo = self.m 
610  616  cs.sqd = to_cseq(training_seqs) 
 617  cs.logp = <double*> safe_malloc(sizeof(double)) 
611  618  cs.eps = log_likelihood_cutoff 
612  619  cs.max_iter = max_iter 
613  620  
614  621  if ghmm_cmodel_baum_welch(&cs): 
615  622  raise RuntimeError, "error running BaumWelch algorithm" 
616   #ghmm_cseq_free(&cs.sqd) 
 623  ghmm_cseq_free(&cs.sqd) 
 624  
617  625  
618  626  cdef ghmm_cseq* to_cseq(seq) except NULL: 
619  627  """ 