/// <summary> /// Computes the normalizer of an automaton by replacing every transition with an epsilon transition /// and computing the value of the automaton on an empty sequence. /// </summary> /// <param name="automaton">The automaton.</param> /// <returns>The logarithm of the normalizer.</returns> private static double GetLogNormalizerByGetValue(StringAutomaton automaton) { var epsilonAutomaton = new StringAutomaton(); epsilonAutomaton = automaton.ApplyFunction <string, char, ImmutableDiscreteChar, StringManipulator, StringAutomaton>( (dist, weight, group) => ValueTuple.Create <Option <ImmutableDiscreteChar>, Weight>(Option.None, weight)); // Convert all the edges to epsilon edges return(epsilonAutomaton.GetLogValue(string.Empty)); // Now this will be exactly the normalizer }