Example #1
0
        /// <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);
        }
Example #2
0
 public double Generate(LabeledObservation pair)
 {
     return(GetEmission(pair));
 }
Example #3
0
 /// <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));
 }
Example #4
0
 public double GetEmission(LabeledObservation pair)
 {
     return(GetEmission(pair.State, pair.Observation));
 }