Exemple #1
0
 /// <summary>
 /// Resets the state of the engine.
 /// </summary>
 public void Reset()
 {
     LatestViterbiStates = new List <ViterbiState <S, T> >()
     {
         ViterbiState <S, T> .InitialState()
     };
 }
Exemple #2
0
 public ViterbiEngine(IHiddenMarkovModel <S, T> model)
 {
     LatestViterbiStates = new List <ViterbiState <S, T> >()
     {
         ViterbiState <S, T> .InitialState()
     };
     Model = model;
 }
Exemple #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);
        }
Exemple #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();
            }
        }
Exemple #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());
 }