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