# Hidden Markov Processes with Silent States

Hidden Markov processes with silent states are often used with rigid topology of hidden states dynamics, i.e. the transition matrix is sparse, to enable transitions between emitting states that are impossible under the chosen topology. Thanks to the structured transition matrix, hidden Markov models with silent states are frequently easier to estimate than their dense analogs.

Define the initial likelihoods of the system being in one of six possible unobservable states as well as the matrix of the conditional transition probabilities between these states.

 In:= XSubscript[p, 0] = {1/2, 1/3, 0, 0, 1/12, 1/12}; \[ScriptCapitalP] = SparseArray[{ {1, 2} -> 0.85, {1, 3} -> 0.15, {2, 3} -> 0.5, {2, 4} -> 0.5, {3, 5} -> 0.65, {3, 4} -> 0.22, {3, 6} -> 0.13, {4, 1} -> 0.25, {4, 3} -> 0.08, {4, 5} -> 0.67, {5, 2} -> 0.3, {5, 6} -> 0.7, {6, 4} -> 0.6, {6, 5} -> 0.4}];

Visualize topology of transitions between hidden states.

 In:= Xgr = Graph[DiscreteMarkovProcess[Subscript[p, 0], \[ScriptCapitalP]], ImageSize -> 300, GraphLayout -> {"MultipartiteEmbedding", "VertexPartition" -> {1, 1, 2, 1, 1}}]
 Out= Define frequencies of the system emitting a categorical signal for every unobservable state. Emissions are labeled 1 through 6. No emissions are made when the system finds itself in either state 3 or state 4; that is, these states are silent.

 In:= Xem = {{1/2, 1/4, 1/8, 1/16, 1/32, 1/32}, {1/32, 1/2, 1/4, 1/8, 1/16, 1/32}, None, None, {1/8, 1/16, 1/32, 1/32, 1/2, 1/4}, {1/4, 1/8, 1/16, 1/32, 1/ 32, 1/2}};

Define hidden Markov process that describes observable emissions.

 In:= Xhmm = HiddenMarkovProcess[Subscript[p, 0], \[ScriptCapitalP], em];

Simulate a sequence of emissions.

 In:= Xemissions = RandomFunction[hmm, {0, 15}]
 Out= Find the most probable sequence of the system's underlying unobservable states.

 In:= XlikelyPath = FindHiddenMarkovStates[emissions, hmm]
 Out= Note that the decoded sequence of states is longer than the sequence of emissions, due to presence of silent states. Visualize the sequence of decoded hidden states.

 In:= XverticesVisited = likelyPath["Values"]; edgesTraversed = DirectedEdge @@@ Partition[verticesVisited, 2, 1]; Find the hidden Markov process without hidden states that assigns the same probabilities for all emission sequences.

 In:= XhmmReduced = HiddenMarkovProcess[hmm]
 Out= Build short sequences of emissions and confirm that both processes assign them equal likelihoods.

 In:= XshortEmissions = Join[Tuples[Range, 1], Tuples[Range, 2], Tuples[Range, 3]];
 In:= XllOriginal = Likelihood[hmm, #] & /@ shortEmissions;
 In:= XllReduced = Likelihood[hmmReduced, #] & /@ shortEmissions;
 In:= XllOriginal == llReduced
 Out= Generate an ensemble of longer emission sequences and use it to estimate parameters of the hidden Markov process with silent states.

 In:= XlongEmissions = RandomFunction[hmm, {0, 100}, 100];
 In:= Xesthmm = EstimatedProcess[longEmissions, HiddenMarkovProcess[6, 6], hmm]
 Out= Compare log-likelihoods of emissions.

 In:= XLogLikelihood[esthmm, longEmissions]
 Out= In:= XLogLikelihood[hmm, longEmissions]
 Out= ## Mathematica

Questions? Comments? Contact a Wolfram expert »