/// <summary>
        /// Evidence message for EP.
        /// </summary>
        /// <param name="allTrue">Constant value for 'allTrue'.</param>
        /// <param name="array">Incoming message from 'array'. Must be a proper distribution.  If any element is uniform, the result will be uniform.</param>
        /// <returns>Logarithm of the factor's average value across the given argument distributions.</returns>
        /// <remarks><para>
        /// The formula for the result is <c>log(sum_(array) p(array) factor(allTrue,array))</c>.
        /// </para></remarks>
        /// <exception cref="ImproperMessageException"><paramref name="array"/> is not a proper distribution</exception>
        public static double LogAverageFactor(bool allTrue, [SkipIfAnyUniform] IList <Bernoulli> array)
        {
            Bernoulli to_allTrue = AllTrueAverageConditional(array);

            return(to_allTrue.GetLogProb(allTrue));
        }
Esempio n. 2
0
		/// <summary>
		/// Evidence message for EP
		/// </summary>
		/// <param name="isGreaterThan">Incoming message from 'isGreaterThan'.</param>
		/// <param name="a">Constant value for 'a'.</param>
		/// <param name="b">Constant value for 'b'.</param>
		/// <returns>Logarithm of the factor's average value across the given argument distributions</returns>
		/// <remarks><para>
		/// The formula for the result is <c>log(sum_(isGreaterThan) p(isGreaterThan) factor(isGreaterThan,a,b))</c>.
		/// </para></remarks>
		public static double LogAverageFactor(Bernoulli isGreaterThan, int a, int b)
		{
			return isGreaterThan.GetLogProb(Factor.IsGreaterThan(a, b));
		}
Esempio n. 3
0
File: And.cs Progetto: 0xCM/arrows
        /// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="BooleanAndOp"]/message_doc[@name="LogAverageFactor(bool, Bernoulli, bool)"]/*'/>
        public static double LogAverageFactor(bool and, Bernoulli a, bool b)
        {
            Bernoulli to_and = AndAverageConditional(a, b);

            return(to_and.GetLogProb(and));
        }
Esempio n. 4
0
File: And.cs Progetto: 0xCM/arrows
 /// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="BooleanAndOp"]/message_doc[@name="LogAverageFactor(Bernoulli, bool, bool)"]/*'/>
 public static double LogAverageFactor(Bernoulli and, bool a, bool b)
 {
     return(and.GetLogProb(Factor.And(a, b)));
 }
Esempio n. 5
0
        /// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="DiscreteAreEqualOp"]/message_doc[@name="LogAverageFactor(bool, Discrete, int)"]/*'/>
        public static double LogAverageFactor(bool areEqual, Discrete A, int B)
        {
            Bernoulli to_areEqual = AreEqualAverageConditional(A, B);

            return(to_areEqual.GetLogProb(areEqual));
        }
		/// <summary>
		/// Evidence message for EP.
		/// </summary>
		/// <param name="and">Incoming message from 'and'.</param>
		/// <param name="a">Constant value for 'a'.</param>
		/// <param name="b">Constant value for 'b'.</param>
		/// <returns>Logarithm of the factor's average value across the given argument distributions.</returns>
		/// <remarks><para>
		/// The formula for the result is <c>log(sum_(and) p(and) factor(and,a,b))</c>.
		/// </para></remarks>
		public static double LogAverageFactor(Bernoulli and, bool a, bool b)
		{
			return and.GetLogProb(Factor.And(a, b));
		}
Esempio n. 7
0
		/// <summary>
		/// Evidence message for EP.
		/// </summary>
		/// <param name="areEqual">Incoming message from 'areEqual'.</param>
		/// <param name="a">Constant value for 'a'.</param>
		/// <param name="b">Constant value for 'b'.</param>
		/// <returns>Logarithm of the factor's average value across the given argument distributions.</returns>
		/// <remarks><para>
		/// The formula for the result is <c>log(sum_(areEqual) p(areEqual) factor(areEqual,a,b))</c>.
		/// </para></remarks>
		public static double LogAverageFactor(Bernoulli areEqual, bool a, bool b)
		{
			return areEqual.GetLogProb(Factor.AreEqual(a, b));
		}
Esempio n. 8
0
 /// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="BooleanAreEqualOp"]/message_doc[@name="LogAverageFactor(Bernoulli, bool, bool)"]/*'/>
 public static double LogAverageFactor(Bernoulli areEqual, bool a, bool b)
 {
     return(areEqual.GetLogProb(Factor.AreEqual(a, b)));
 }
        /// <summary>
        /// Evidence message for EP
        /// </summary>
        /// <param name="or">Constant value for 'or'.</param>
        /// <param name="a">Incoming message from 'a'.</param>
        /// <param name="b">Constant value for 'b'.</param>
        /// <returns>Logarithm of the factor's average value across the given argument distributions</returns>
        /// <remarks><para>
        /// The formula for the result is <c>log(sum_(a) p(a) factor(or,a,b))</c>.
        /// </para></remarks>
        public static double LogAverageFactor(bool or, Bernoulli a, bool b)
        {
            Bernoulli to_or = OrAverageConditional(a, b);

            return(to_or.GetLogProb(or));
        }
 /// <summary>
 /// Evidence message for EP
 /// </summary>
 /// <param name="or">Incoming message from 'or'.</param>
 /// <param name="a">Constant value for 'a'.</param>
 /// <param name="b">Constant value for 'b'.</param>
 /// <returns>Logarithm of the factor's average value across the given argument distributions</returns>
 /// <remarks><para>
 /// The formula for the result is <c>log(sum_(or) p(or) factor(or,a,b))</c>.
 /// </para></remarks>
 public static double LogAverageFactor(Bernoulli or, bool a, bool b)
 {
     return(or.GetLogProb(Factor.Or(a, b)));
 }
Esempio n. 11
0
        /// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="StringsAreEqualOp"]/message_doc[@name="LogAverageFactor(bool, StringDistribution, StringDistribution)"]/*'/>
        public static double LogAverageFactor(bool areEqual, StringDistribution str1, StringDistribution str2)
        {
            Bernoulli messageToAreEqual = AreEqualAverageConditional(str1, str2);

            return(messageToAreEqual.GetLogProb(areEqual));
        }
Esempio n. 12
0
        /// <summary>Evidence message for EP.</summary>
        /// <param name="sample">Constant value for <c>sample</c>.</param>
        /// <param name="probTrue">Incoming message from <c>probTrue</c>.</param>
        /// <returns>Logarithm of the factor's average value across the given argument distributions.</returns>
        /// <remarks>
        ///   <para>The formula for the result is <c>log(sum_(probTrue) p(probTrue) factor(sample,probTrue))</c>.</para>
        /// </remarks>
        public static double LogAverageFactor(bool sample, Beta probTrue)
        {
            Bernoulli to_sample = SampleAverageConditional(probTrue);

            return(to_sample.GetLogProb(sample));
        }
Esempio n. 13
0
 /// <summary>
 /// Returns the negative natural logarithm of the probability of ground truth for a given predictive distribution.
 /// </summary>
 /// <param name="groundTruth">The ground truth.</param>
 /// <param name="prediction">The prediction as a <see cref="Discrete"/> distribution.</param>
 /// <returns>The negative natural logarithm of the probability of <paramref name="groundTruth"/>.</returns>
 public static double NegativeLogProbability(bool groundTruth, Bernoulli prediction)
 {
     return(-prediction.GetLogProb(groundTruth));
 }
Esempio n. 14
0
		/// <summary>
		/// Evidence message for EP
		/// </summary>
		/// <param name="or">Incoming message from 'or'.</param>
		/// <param name="a">Constant value for 'a'.</param>
		/// <param name="b">Constant value for 'b'.</param>
		/// <returns>Logarithm of the factor's average value across the given argument distributions</returns>
		/// <remarks><para>
		/// The formula for the result is <c>log(sum_(or) p(or) factor(or,a,b))</c>.
		/// </para></remarks>
		public static double LogAverageFactor(Bernoulli or, bool a, bool b)
		{
			return or.GetLogProb(Factor.Or(a, b));
		}
Esempio n. 15
0
 /// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="IsGreaterThanOp"]/message_doc[@name="LogAverageFactor(Bernoulli, int, int)"]/*'/>
 public static double LogAverageFactor(Bernoulli isGreaterThan, int a, int b)
 {
     return(isGreaterThan.GetLogProb(Factor.IsGreaterThan(a, b)));
 }