コード例 #1
0
ファイル: Viterbi.cs プロジェクト: ArxCaeli/hmm_lab1
 private void BeginningStep()
 {
     for (int I = 0; I < m_WorkingStates.Count; I++)
         Results[0, I] = new ViterbiResult(
             0, m_BeginingState.Name, m_BeginingState.Name, 1);
 }
コード例 #2
0
ファイル: Viterbi.cs プロジェクト: ArxCaeli/hmm_lab1
        private void MakeStep(int Pos, HMM State, int ArrayStateIndex)
        {
            double PrevMaxStateValue = 0;
            string PrevStateName = "";
            for (int I = 0; I < m_WorkingStates.Count; I++)
            {
                HMM PrevState = (Pos == 1) ? m_BeginingState : m_WorkingStates[I];
                double PrevStateValue = Results[Pos - 1, I].Possibility *
                    PrevState.GetTransitionStrength(State.Name);

                if (PrevStateValue > PrevMaxStateValue)
                {
                    PrevMaxStateValue = PrevStateValue;
                    PrevStateName = PrevState.Name;
                }
            }

            double Emission =
                (Pos == m_Sequence.Count + 1) ?
                    1 : State.GetEmmisionStrength(m_Sequence[Pos - 1].Sequence);

            Results[Pos, ArrayStateIndex] = new ViterbiResult(
                Pos, State.Name, PrevStateName, Emission * PrevMaxStateValue);
        }