コード例 #1
0
        /// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="StringFromArrayOp"]/message_doc[@name="CharactersAverageConditional{TDiscreteCharList}(StringDistribution, IList{DiscreteChar}, TDiscreteCharList)"]/*'/>
        /// <typeparam name="TDiscreteCharList">The type of an outgoing message to <c>chars</c>.</typeparam>
        public static TDiscreteCharList CharactersAverageConditional <TDiscreteCharList>(
            StringDistribution str, IList <DiscreteChar> characters, TDiscreteCharList result)
            where TDiscreteCharList : IList <DiscreteChar>
        {
            for (int i = 0; i < characters.Count; ++i)
            {
                // TODO: perhaps there is a faster way to extract the distribution of interest
                var reweightedStr        = str.Product(GetCharWeighter(characters, i));
                var outgoingMessageAsStr = SubstringOp.SubAverageConditional(reweightedStr, i, 1);
                if (outgoingMessageAsStr.IsZero())
                {
                    throw new AllZeroException("Impossible model detected in StringFromCharsOp.");
                }

                result[i] = SingleOp.CharacterAverageConditional(outgoingMessageAsStr);
            }

            return(result);
        }
コード例 #2
0
        /// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="StringCharConcatOp"]/message_doc[@name="ChAverageConditional(StringDistribution, StringDistribution)"]/*'/>
        public static DiscreteChar ChAverageConditional(StringDistribution concat, StringDistribution str)
        {
            var result = StringConcatOp.Str2AverageConditional(concat, str);

            return(SingleOp.CharacterAverageConditional(result));
        }