/// <summary> /// Gets the probability of a sequence starting with the <paramref name="left"/> /// hypothesis and ending with the <paramref name="right"/> one. /// </summary> /// <param name="left">The left state as seen with the observation.</param> /// <param name="right">The right state as seen with the observation.</param> /// <returns>System.Double.</returns> public double GetProbability( LabeledObservation left, LabeledObservation right) { #if true var p = _inital.GetProbability(left.State) * _emission.GetEmission(left) * _transition.GetTransition(left.State, right.State) * _emission.GetEmission(right); #else // using Log-Likelihoods var p = Math.Exp(Math.Log(_inital.GetProbability(left.State)) + Math.Log(_emission.GetEmission(left)) + Math.Log(_transition.GetTransition(left.State, right.State)) + Math.Log(_emission.GetEmission(right))); if (Double.IsInfinity(p)) { return(0); } #endif return(p); }
public double Generate(LabeledObservation pair) { return(GetEmission(pair)); }
/// <summary> /// Determines whether the specified <see cref="LabeledObservation" /> is equal to this instance. /// </summary> /// <param name="other">Another object to compare to.</param> /// <returns><see langword="true" /> if the specified <see cref="LabeledObservation" /> is equal to this instance; otherwise, <see langword="false" />.</returns> public bool Equals(LabeledObservation other) { return(State.Equals(other.State) && Observation.Equals(other.Observation)); }
public double GetEmission(LabeledObservation pair) { return(GetEmission(pair.State, pair.Observation)); }