Ejemplo n.º 1
0
 /**
  * Test example train
  *
  * As documented here:
  * http://www.indiana.edu/~iulg/moss/hmmcalculations.pdf
  * 
  * @return void
  */
 public function testSimpleTrain()
 {
     $hmm = new slHiddenMarkovModel(2, array('A', 'B'));
     // Initialize the model
     $hmm->setStart(0, 0.85);
     $hmm->setStart(1, 0.15);
     $hmm->setTransition(0, 0, 0.3);
     $hmm->setTransition(0, 1, 0.7);
     $hmm->setTransition(1, 0, 0.1);
     $hmm->setTransition(1, 1, 0.9);
     $hmm->setEmission(0, 0, 0.4);
     $hmm->setEmission(0, 1, 0.6);
     $hmm->setEmission(1, 0, 0.5);
     $hmm->setEmission(1, 1, 0.5);
     $trainer = new slBaumWelchTrainer();
     $trainer->trainCycle($hmm, array('A', 'B', 'B', 'A'), 1);
     $trainer->trainCycle($hmm, array('B', 'A', 'B'), 1);
 }