Example #1
0
 /// <summary>
 /// Resets the state of the engine.
 /// </summary>
 public void Reset()
 {
     LatestViterbiStates = new List <ViterbiState <S, T> >()
     {
         ViterbiState <S, T> .InitialState()
     };
 }
Example #2
0
 public ViterbiEngine(IHiddenMarkovModel <S, T> model)
 {
     LatestViterbiStates = new List <ViterbiState <S, T> >()
     {
         ViterbiState <S, T> .InitialState()
     };
     Model = model;
 }
Example #3
0
        public static ViterbiState <S, T> InitialState()
        {
            var result = new ViterbiState <S, T>();

            result.Probabilities    = new ProbabilityVector <S>();
            result.TransitionMemory = new List <Dictionary <S, S> >();
            return(result);
        }
Example #4
0
        private void UpdateViterbiState(ProbabilityVector <S> probabilities, T prevObservation, Dictionary <S, S> transitions)
        {
            var newTransitionMemory = ViterbiState.TransitionMemory.ToList();

            newTransitionMemory.Add(transitions);
            var newViterbiState = new ViterbiState <S, T>(probabilities, prevObservation, newTransitionMemory);

            LatestViterbiStates.Add(newViterbiState);
            if (LatestViterbiStates.Count > _stateHistoryDepth)
            {
                LatestViterbiStates = LatestViterbiStates.Skip(1).ToList();
            }
        }
Example #5
0
 /// <summary>
 /// Gets the most likely sequence of states given the current state of the engine.
 /// </summary>
 /// <returns></returns>
 public List <S> GetMostLikelySequence()
 {
     return(ViterbiState.GetMostLikelySequence());
 }