List<List<ObservationDiscrete<Packet>>> sequences;
sequences = generateSequences(hmm);
/* Baum-Welch learning */
BaumWelchLearner bwl = new BaumWelchLearner();
Hmm<ObservationDiscrete<Packet>> learntHmm = buildInitHmm();
// This object measures the distance between two HMMs
KullbackLeiblerDistanceCalculator klc =
new KullbackLeiblerDistanceCalculator();
// Incrementally improve the solution
for (int i = 0; i < 10; i++) {
System.out.println("Distance at iteration " + i + ": " +
klc.distance(learntHmm, hmm));
learntHmm = bwl.iterate(learntHmm, sequences);
}
System.out.println("Resulting HMM:\n" + learntHmm);
/* Computing the probability of a sequence */