Initialization of an HMM before using ForwardCalculator

63 views
Skip to first unread message

martar

unread,
Sep 25, 2014, 2:37:04 PM9/25/14
to jahmm-...@googlegroups.com
Hello,

I need to use the Forward Calculator but in order to do this I want to initialize an HMM with pi, Ai, Bi parameters that have emerged from  the training of the model.

I did the training using Baum Welch and matlab now I need to incorporate it to my java project.

To set pi parameter I I did double pi[]=new double[] {0.25, 0.25, 0.25, 0.25}; To set ai = new double[][]{{0.024243953, 1.82E-88,0.941441547,0.0343145 },{0.009817181, 0.985312485,6.10E-13,0.004870334},{0.074292472, 0.587254772,0.160856373,0.177596383},{0.012133549, 0.114251811, 0.01059446, 0.86302018 }};

but I have difficulty in initalizing B.  How can I set initial values to B in order to create the HMM model by using the constructor like this Hmm hmm1 =  new Hmm(pi,ai,bi)?
I know the values but I am a  bit confused with Opdfs.
Generally is this a good approach?

Any help is appreciated. Thank you in advance.

martar

unread,
Sep 25, 2014, 3:33:34 PM9/25/14
to jahmm-...@googlegroups.com
Finally I used this method
 OpdfDiscreteFactory<SimpleExample.Packet> factory =
                new OpdfDiscreteFactory<SimpleExample.Packet>(SimpleExample.Packet.class);
        Hmm<ObservationDiscrete<SimpleExample.Packet>> hmm =
                new Hmm<ObservationDiscrete<SimpleExample.Packet>>(4, factory);

        hmm.setPi(0, 0.25);
      ..............................

        hmm.setOpdf(0, new OpdfDiscrete<SimpleExample.Packet>(SimpleExample.Packet.class, new double[] { 6.43E-01, 6.05E-197, 6.58E-101, 5.41E-220, 7.10E-45, 0.027582667, 0.00E+00, 4.25E-184, 3.37E-61, 4.64E-156, 4.55E-212, 1.02E-108, 3.29E-01, 2.41E-91, 6.22E-53 }));
...................................

      

        hmm.setAij(0, 0, 0.16152514);
        hmm.setAij(0, 1, 0.034003153);
        hmm.setAij(0, 2, 1.69E-107);
        hmm.setAij(0, 3, 0.804471706);
       ..........................................

I guess this is the correct approach.
Reply all
Reply to author
Forward
0 new messages