/* * BioJava development code * * This code may be freely distributed and modified under the * terms of the GNU Lesser General Public Licence. This should * be distributed with the code. If you do not have a copy, * see: * * http://www.gnu.org/copyleft/lesser.html * * Copyright for this code is held jointly by the individual * authors. These should be listed in @author doc comments. * * For more information on the BioJava project and its aims, * or to join the biojava-l mailing list, visit the home page * at: * * http://www.biojava.org/ * */ package dp; import org.biojava.utils.*; import org.biojava.bio.*; import org.biojava.bio.symbol.*; import org.biojava.bio.dist.*; import org.biojava.bio.dp.*; /** * This demo file is a simulation of the "The occasionally dishonest casino" example * from the book by R. Durbin, S. Eddy, A. Krogh, G. Mitchison, * "Biological Sequence Analysis", * Chapter 3 Markov Chains and hidden Markov models, Section 2, pp55-57. *

* Use: Dice *

* The output consists of three lines: line 1 represents the output sequence generated * by the hidden markov model (f for fair and l for loaded). Line 2 contains the name of * the die which emitted the corresponding output symbol. Line 3 shows the state * sequence predicted by the Viterbi algorithm. *

* * @author Samiul Hasan */ public class Dice { public static void main(String[] args) { try { MarkovModel casino = createCasino(); DP dp=DPFactory.DEFAULT.createDP(casino); StatePath obs_rolls = dp.generate(300); SymbolList roll_sequence = obs_rolls.symbolListForLabel(StatePath.SEQUENCE); SymbolList[] res_array = {roll_sequence}; StatePath v = dp.viterbi(res_array, ScoreType.PROBABILITY); //print out obs_sequence, output, state symbols. // for(int i = 1; i <= obs_rolls.length()/60; i++) { // for(int j=i*60; j