Create HW3 partially Observed HMM

Continuing on the biased coin example in lecture 10, now suppose that the coin jumps between two
different biased states: state #1 and state #2. Suppose that the initial probability is π = (p, 1−p),
i.e., the coin is initially (for the first toss) in state #1 with probability p and in state #2 with
probability 1 − p. The transition probabilities between adjacent tosses are given by the following
matrix (e.g., if the coin is in state #1 for the i-th toss, then the coin will jump to state #2 with
probability 1 − a1 for the (i + 1)-th toss).
A =
(
a1 1 − a1
a2 1 − a2
)
Furthermore, the emission probabilities are given by the following matrix (e.g., the probability of
observing an outcome of head (denoted as H) for each toss is b1 in state #1 and the probability of
observing an outcome of tail (denoted as T) for each toss is 1 − b2 in state #2).
B =
(
b1 1 − b1
b2 1 − b2
)
Write a C++ program partialHMM.cpp which, given p, a1, a2, b1, b2 and a sequence of partially
observed outcomes (“H” and “T” represent observed outcomes and “.” represents unobserved
outcome) for a sequence of tosses, computes and prints a complete sequence of outcomes by filling
in each unobserved outcome with the most likely outcome for that toss (i.e., the outcome with the
largest marginal probability). Print T if the marginal probability for an unobserved outcome is
greater than or equal to 0.5 for outcome T, and print H otherwise. Your program should get its
input from argv. You can assume that p, a1, a2, b1 and b2 are real numbers between 0 and 1 (with
0 and 1 included). You may modify the forward-backward algorithm given in lectures. Example
runs of valid input arguments are (the first line is the command line and the second line is the
expected output of your program).

Note: Missed a few test cases