# 有沉默状态的隐马尔可夫过程

 In[1]:= 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}];

 In[2]:= Xgr = Graph[DiscreteMarkovProcess[Subscript[p, 0], \[ScriptCapitalP]], ImageSize -> 300, GraphLayout -> {"MultipartiteEmbedding", "VertexPartition" -> {1, 1, 2, 1, 1}}]
 Out[2]=

 In[3]:= 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}};

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

 In[5]:= Xemissions = RandomFunction[hmm, {0, 15}]
 Out[5]=

 In[6]:= XlikelyPath = FindHiddenMarkovStates[emissions, hmm]
 Out[6]=

 In[7]:= XverticesVisited = likelyPath["Values"]; edgesTraversed = DirectedEdge @@@ Partition[verticesVisited, 2, 1];

 In[8]:= XhmmReduced = HiddenMarkovProcess[hmm]
 Out[8]=

 In[9]:= XshortEmissions = Join[Tuples[Range[6], 1], Tuples[Range[6], 2], Tuples[Range[6], 3]];
 In[10]:= XllOriginal = Likelihood[hmm, #] & /@ shortEmissions;
 In[11]:= XllReduced = Likelihood[hmmReduced, #] & /@ shortEmissions;
 In[12]:= XllOriginal == llReduced
 Out[12]=

 In[13]:= XlongEmissions = RandomFunction[hmm, {0, 100}, 100];
 In[14]:= Xesthmm = EstimatedProcess[longEmissions, HiddenMarkovProcess[6, 6], hmm]
 Out[14]=

 In[15]:= XLogLikelihood[esthmm, longEmissions]
 Out[15]=
 In[16]:= XLogLikelihood[hmm, longEmissions]
 Out[16]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »