/// <summary>EP message to <c>str</c>.</summary> /// <param name="allowedChars">Constant value for <c>allowedChars</c>.</param> /// <param name="length">Constant value for <c>length</c>.</param> /// <returns>The outgoing EP message to the <c>str</c> argument.</returns> /// <remarks> /// <para>The outgoing message is the factor viewed as a function of <c>str</c> conditioned on the given values.</para> /// </remarks> public static StringDistribution StrAverageConditional(DiscreteChar allowedChars, int length) { Argument.CheckIfNotNull(allowedChars, "allowedChars"); Argument.CheckIfValid(allowedChars.IsPartialUniform(), "allowedChars", "The set of allowed characters must be passed as a partial uniform distribution."); return(StringDistribution.Repeat(allowedChars, length, length)); }
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="StringOfLengthOp"]/message_doc[@name="StrAverageConditional(DiscreteChar, Discrete)"]/*'/> public static StringDistribution StrAverageConditional(DiscreteChar allowedChars, Discrete length) { Argument.CheckIfNotNull(length, "length"); Argument.CheckIfValid(allowedChars.IsPartialUniform(), "allowedChars", "The set of allowed characters must be passed as a partial uniform distribution."); double logNormalizer = allowedChars.GetLogAverageOf(allowedChars); var oneCharacter = StringAutomaton.ConstantOnElementLog(logNormalizer, allowedChars.WrappedDistribution); var manyCharacters = StringAutomaton.Repeat(oneCharacter, length.GetWorkspace()); return(StringDistribution.FromWeightFunction(manyCharacters)); }