-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMain.java
42 lines (37 loc) · 1.3 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import static java.lang.System.*;
class HM
{
public static void main(String [] args)
{
out.println("Yup!!");
out.println("We have enetered in implementation phase/n1.Forward Algorithm/n2.Viterbi Algorithm");
int obs[] = {3, 3, 2, 2, 1, 1, 3, 1, 3};
int states[] = {0, 1, 2, 3}; // 0-Mon, 1-Tue, 2-Wed, 3-Thu.
double start_prob[] = {1, 1, 1, 1};
double trans_prob[][] =
{
{0, 0.8, 0.2, 0},
{0, 0.6, 0.3, 0.1},
{0, 0.4, 0.5, 0.1},
{0, 0, 0, 0}
};
double emiss_prob[][] =
{
{0, 0, 0},
{0.2, 0.4, 0.4},
{0.5, 0.4, 0.1},
{0, 0, 0}
};
// Forward object creation
Forward obj = new Forward();
out.println("------Forward Algorithm------");
double final_prob = obj.compute(obs, states, start_prob, trans_prob, emiss_prob);
out.println("The final probability for the given observation is "+ final_prob);
// Backward object creation
Backward obj2 = new Backward();
out.println("------Backward Algorithm------");
//double final_prob1 = obj2.compute(obs, states, start_prob, trans_prob, emiss_prob);
out.println("The final probability for the given observation with Backward probability is "+ final_prob);
out.println("------End------");
}
}