Example #1
0
 /// <summary>VMP message to <c>b</c>.</summary>
 /// <param name="areEqual">Constant value for <c>areEqual</c>.</param>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="result">Modified to contain the outgoing message.</param>
 /// <returns>
 ///   <paramref name="result" />
 /// </returns>
 /// <remarks>
 ///   <para>The outgoing message is the exponential of the average log-factor value, where the average is over all arguments except <c>b</c>. The formula is <c>exp(sum_(a) p(a) log(factor(areEqual,a,b)))</c>.</para>
 /// </remarks>
 public static DiscreteEnum <TEnum> BAverageLogarithm(bool areEqual, TEnum A, DiscreteEnum <TEnum> result)
 {
     return(DiscreteEnum <TEnum> .FromDiscrete(DiscreteAreEqualOp.BAverageLogarithm(areEqual, ToInt(A), result.GetInternalDiscrete())));
 }
Example #2
0
 /// <summary>EP message to <c>areEqual</c>.</summary>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="B">Incoming message from <c>b</c>.</param>
 /// <returns>The outgoing EP message to the <c>areEqual</c> argument.</returns>
 /// <remarks>
 ///   <para>The outgoing message is a distribution matching the moments of <c>areEqual</c> as the random arguments are varied. The formula is <c>proj[p(areEqual) sum_(a,b) p(a,b) factor(areEqual,a,b)]/p(areEqual)</c>.</para>
 /// </remarks>
 public static Bernoulli AreEqualAverageConditional(DiscreteEnum <TEnum> A, TEnum B)
 {
     return(DiscreteAreEqualOp.AreEqualAverageConditional(A.GetInternalDiscrete(), ToInt(B)));
 }
 /// <summary>
 /// EP message to 'b'
 /// </summary>
 /// <param name="areEqual">Constant value for 'areEqual'.</param>
 /// <param name="A">Constant value for 'a'.</param>
 /// <param name="result">Modified to contain the outgoing message</param>
 /// <returns><paramref name="result"/></returns>
 /// <remarks><para>
 /// The outgoing message is the factor viewed as a function of 'b' conditioned on the given values.
 /// </para></remarks>
 public static DiscreteEnum <TEnum> BAverageConditional(bool areEqual, TEnum A, Discrete result)
 {
     return(new DiscreteEnum <TEnum>(DiscreteAreEqualOp.BAverageConditional(areEqual, ToInt(A), result)));
 }
Example #4
0
 /// <summary>VMP message to <c>b</c>.</summary>
 /// <param name="areEqual">Incoming message from <c>areEqual</c>. Must be a proper distribution. If uniform, the result will be uniform.</param>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="result">Modified to contain the outgoing message.</param>
 /// <returns>
 ///   <paramref name="result" />
 /// </returns>
 /// <remarks>
 ///   <para>The outgoing message is the exponential of the average log-factor value, where the average is over all arguments except <c>b</c>. Because the factor is deterministic, <c>areEqual</c> is integrated out before taking the logarithm. The formula is <c>exp(sum_(a) p(a) log(sum_areEqual p(areEqual) factor(areEqual,a,b)))</c>.</para>
 /// </remarks>
 /// <exception cref="ImproperMessageException">
 ///   <paramref name="areEqual" /> is not a proper distribution.</exception>
 public static DiscreteEnum <TEnum> BAverageLogarithm([SkipIfUniform] Bernoulli areEqual, TEnum A, DiscreteEnum <TEnum> result)
 {
     return(DiscreteEnum <TEnum> .FromDiscrete(DiscreteAreEqualOp.BAverageLogarithm(areEqual, ToInt(A), result.GetInternalDiscrete())));
 }
Example #5
0
 /// <summary>Evidence message for EP.</summary>
 /// <param name="areEqual">Constant value for <c>areEqual</c>.</param>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="B">Incoming message from <c>b</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_(a,b) p(a,b) factor(areEqual,a,b))</c>.</para>
 /// </remarks>
 public static double LogAverageFactor(bool areEqual, DiscreteEnum <TEnum> A, TEnum B)
 {
     return(DiscreteAreEqualOp.LogAverageFactor(areEqual, A.GetInternalDiscrete(), ToInt(B)));
 }
Example #6
0
 /// <summary>Evidence message for EP.</summary>
 /// <param name="areEqual">Constant value for <c>areEqual</c>.</param>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="B">Incoming message from <c>b</c>.</param>
 /// <param name="to_A">Outgoing message to <c>A</c>.</param>
 /// <returns>Logarithm of the factor's contribution the EP model evidence.</returns>
 /// <remarks>
 ///   <para>The formula for the result is <c>log(sum_(a,b) p(a,b) factor(areEqual,a,b))</c>. Adding up these values across all factors and variables gives the log-evidence estimate for EP.</para>
 /// </remarks>
 public static double LogEvidenceRatio(bool areEqual, DiscreteEnum <TEnum> A, TEnum B, [Fresh] DiscreteEnum <TEnum> to_A)
 {
     return(DiscreteAreEqualOp.LogEvidenceRatio(areEqual, A.GetInternalDiscrete(), ToInt(B), to_A.GetInternalDiscrete()));
 }
 /// <summary>
 /// VMP message to 'areEqual'
 /// </summary>
 /// <param name="A">Incoming message from 'a'.</param>
 /// <param name="B">Constant value for 'b'.</param>
 /// <returns>The outgoing VMP message to the 'areEqual' argument</returns>
 /// <remarks><para>
 /// The outgoing message is a distribution matching the moments of 'areEqual' as the random arguments are varied.
 /// The formula is <c>proj[sum_(a) p(a) factor(areEqual,a,b)]</c>.
 /// </para></remarks>
 public static Bernoulli AreEqualAverageLogarithm(Discrete A, TEnum B)
 {
     return(DiscreteAreEqualOp.AreEqualAverageLogarithm(A, ToInt(B)));
 }
Example #8
0
 /// <summary>Evidence message for EP.</summary>
 /// <param name="areEqual">Constant value for <c>areEqual</c>.</param>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="B">Incoming message from <c>b</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_(a,b) p(a,b) factor(areEqual,a,b))</c>.</para>
 /// </remarks>
 public static double LogAverageFactor(bool areEqual, TEnum A, TEnum B)
 {
     return(DiscreteAreEqualOp.LogAverageFactor(areEqual, ToInt(A), ToInt(B)));
 }
 /// <summary>
 /// EP message to 'areEqual'
 /// </summary>
 /// <param name="A">Incoming message from 'a'.</param>
 /// <param name="B">Constant value for 'b'.</param>
 /// <returns>The outgoing EP message to the 'areEqual' argument</returns>
 /// <remarks><para>
 /// The outgoing message is a distribution matching the moments of 'areEqual' as the random arguments are varied.
 /// The formula is <c>proj[p(areEqual) sum_(a) p(a) factor(areEqual,a,b)]/p(areEqual)</c>.
 /// </para></remarks>
 public static Bernoulli AreEqualAverageConditional(Discrete A, TEnum B)
 {
     return(DiscreteAreEqualOp.AreEqualAverageConditional(A, ToInt(B)));
 }
 /// <summary>
 /// VMP message to 'areEqual'
 /// </summary>
 /// <param name="A">Constant value for 'a'.</param>
 /// <param name="B">Incoming message from 'b'.</param>
 /// <returns>The outgoing VMP message to the 'areEqual' argument</returns>
 /// <remarks><para>
 /// The outgoing message is a distribution matching the moments of 'areEqual' as the random arguments are varied.
 /// The formula is <c>proj[sum_(b) p(b) factor(areEqual,a,b)]</c>.
 /// </para></remarks>
 public static Bernoulli AreEqualAverageLogarithm(TEnum A, Discrete B)
 {
     return(DiscreteAreEqualOp.AreEqualAverageLogarithm(ToInt(A), B));
 }
 /// <summary>
 /// EP message to 'areEqual'
 /// </summary>
 /// <param name="A">Constant value for 'a'.</param>
 /// <param name="B">Incoming message from 'b'.</param>
 /// <returns>The outgoing EP message to the 'areEqual' argument</returns>
 /// <remarks><para>
 /// The outgoing message is a distribution matching the moments of 'areEqual' as the random arguments are varied.
 /// The formula is <c>proj[p(areEqual) sum_(b) p(b) factor(areEqual,a,b)]/p(areEqual)</c>.
 /// </para></remarks>
 public static Bernoulli AreEqualAverageConditional(TEnum A, Discrete B)
 {
     return(DiscreteAreEqualOp.AreEqualAverageConditional(ToInt(A), B));
 }
 /// <summary>
 /// VMP message to 'b'
 /// </summary>
 /// <param name="areEqual">Constant value for 'areEqual'.</param>
 /// <param name="A">Constant value for 'a'.</param>
 /// <param name="result">Modified to contain the outgoing message</param>
 /// <returns><paramref name="result"/></returns>
 /// <remarks><para>
 /// The outgoing message is the factor viewed as a function of 'b' conditioned on the given values.
 /// </para></remarks>
 public static DiscreteEnum <TEnum> BAverageLogarithm(bool areEqual, TEnum A, Discrete result)
 {
     return(new DiscreteEnum <TEnum>(DiscreteAreEqualOp.BAverageLogarithm(areEqual, ToInt(A), result)));
 }
 /// <summary>
 /// VMP message to 'b'
 /// </summary>
 /// <param name="areEqual">Incoming message from 'areEqual'. Must be a proper distribution.  If uniform, the result will be uniform.</param>
 /// <param name="A">Constant value for 'a'.</param>
 /// <param name="result">Modified to contain the outgoing message</param>
 /// <returns><paramref name="result"/></returns>
 /// <remarks><para>
 /// The outgoing message is the factor viewed as a function of 'b' with 'areEqual' integrated out.
 /// The formula is <c>sum_areEqual p(areEqual) factor(areEqual,a,b)</c>.
 /// </para></remarks>
 /// <exception cref="ImproperMessageException"><paramref name="areEqual"/> is not a proper distribution</exception>
 public static DiscreteEnum <TEnum> BAverageLogarithm([SkipIfUniform] Bernoulli areEqual, TEnum A, Discrete result)
 {
     return(new DiscreteEnum <TEnum>(DiscreteAreEqualOp.BAverageLogarithm(areEqual, ToInt(A), result)));
 }
Example #14
0
 /// <summary>VMP message to <c>areEqual</c>.</summary>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="B">Incoming message from <c>b</c>.</param>
 /// <returns>The outgoing VMP message to the <c>areEqual</c> argument.</returns>
 /// <remarks>
 ///   <para>The outgoing message is a distribution matching the moments of <c>areEqual</c> as the random arguments are varied. The formula is <c>proj[sum_(a,b) p(a,b) factor(areEqual,a,b)]</c>.</para>
 /// </remarks>
 public static Bernoulli AreEqualAverageLogarithm(TEnum A, DiscreteEnum <TEnum> B)
 {
     return(DiscreteAreEqualOp.AreEqualAverageLogarithm(ToInt(A), B.GetInternalDiscrete()));
 }
 /// <summary>
 /// Evidence message for EP
 /// </summary>
 /// <param name="areEqual">Constant value for 'areEqual'.</param>
 /// <param name="A">Constant value for 'a'.</param>
 /// <param name="B">Incoming message from 'b'.</param>
 /// <param name="to_B">Outgoing message to 'B'.</param>
 /// <returns>Logarithm of the factor's contribution the EP model evidence</returns>
 /// <remarks><para>
 /// The formula for the result is <c>log(sum_(b) p(b) factor(areEqual,a,b))</c>.
 /// Adding up these values across all factors and variables gives the log-evidence estimate for EP.
 /// </para></remarks>
 public static double LogEvidenceRatio(bool areEqual, TEnum A, Discrete B, [Fresh] Discrete to_B)
 {
     return(DiscreteAreEqualOp.LogEvidenceRatio(areEqual, ToInt(A), B, to_B));
 }
Example #16
0
 /// <summary>VMP message to <c>areEqual</c>.</summary>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="B">Incoming message from <c>b</c>.</param>
 /// <returns>The outgoing VMP message to the <c>areEqual</c> argument.</returns>
 /// <remarks>
 ///   <para>The outgoing message is a distribution matching the moments of <c>areEqual</c> as the random arguments are varied. The formula is <c>proj[sum_(a,b) p(a,b) factor(areEqual,a,b)]</c>.</para>
 /// </remarks>
 public static Bernoulli AreEqualAverageLogarithm(DiscreteEnum <TEnum> A, TEnum B)
 {
     return(DiscreteAreEqualOp.AreEqualAverageLogarithm(A.GetInternalDiscrete(), ToInt(B)));
 }
 /// <summary>
 /// Evidence message for EP
 /// </summary>
 /// <param name="areEqual">Constant value for 'areEqual'.</param>
 /// <param name="A">Incoming message from 'a'.</param>
 /// <param name="B">Constant value for 'b'.</param>
 /// <param name="to_A">Outgoing message to 'A'.</param>
 /// <returns>Logarithm of the factor's contribution the EP model evidence</returns>
 /// <remarks><para>
 /// The formula for the result is <c>log(sum_(a) p(a) factor(areEqual,a,b))</c>.
 /// Adding up these values across all factors and variables gives the log-evidence estimate for EP.
 /// </para></remarks>
 public static double LogEvidenceRatio(bool areEqual, Discrete A, TEnum B, [Fresh] Discrete to_A)
 {
     return(DiscreteAreEqualOp.LogEvidenceRatio(areEqual, A, ToInt(B), to_A));
 }
Example #18
0
 /// <summary>Evidence message for EP.</summary>
 /// <param name="areEqual">Constant value for <c>areEqual</c>.</param>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="B">Incoming message from <c>b</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_(a,b) p(a,b) factor(areEqual,a,b))</c>.</para>
 /// </remarks>
 public static double LogAverageFactor(bool areEqual, TEnum A, DiscreteEnum <TEnum> B)
 {
     return(DiscreteAreEqualOp.LogAverageFactor(areEqual, ToInt(A), B.GetInternalDiscrete()));
 }
Example #19
0
 /// <summary>EP message to <c>a</c>.</summary>
 /// <param name="areEqual">Incoming message from <c>areEqual</c>. Must be a proper distribution. If uniform, the result will be uniform.</param>
 /// <param name="B">Incoming message from <c>b</c>.</param>
 /// <param name="result">Modified to contain the outgoing message.</param>
 /// <returns>
 ///   <paramref name="result" />
 /// </returns>
 /// <remarks>
 ///   <para>The outgoing message is a distribution matching the moments of <c>a</c> as the random arguments are varied. The formula is <c>proj[p(a) sum_(areEqual,b) p(areEqual,b) factor(areEqual,a,b)]/p(a)</c>.</para>
 /// </remarks>
 /// <exception cref="ImproperMessageException">
 ///   <paramref name="areEqual" /> is not a proper distribution.</exception>
 public static DiscreteEnum <TEnum> AAverageConditional([SkipIfUniform] Bernoulli areEqual, TEnum B, DiscreteEnum <TEnum> result)
 {
     return(DiscreteEnum <TEnum> .FromDiscrete(DiscreteAreEqualOp.AAverageConditional(areEqual, ToInt(B), result.GetInternalDiscrete())));
 }
Example #20
0
 /// <summary>Evidence message for EP.</summary>
 /// <param name="areEqual">Constant value for <c>areEqual</c>.</param>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="B">Incoming message from <c>b</c>.</param>
 /// <param name="to_B">Outgoing message to <c>B</c>.</param>
 /// <returns>Logarithm of the factor's contribution the EP model evidence.</returns>
 /// <remarks>
 ///   <para>The formula for the result is <c>log(sum_(a,b) p(a,b) factor(areEqual,a,b))</c>. Adding up these values across all factors and variables gives the log-evidence estimate for EP.</para>
 /// </remarks>
 public static double LogEvidenceRatio(bool areEqual, TEnum A, DiscreteEnum <TEnum> B, [Fresh] DiscreteEnum <TEnum> to_B)
 {
     return(DiscreteAreEqualOp.LogEvidenceRatio(areEqual, ToInt(A), B.GetInternalDiscrete(), to_B.GetInternalDiscrete()));
 }
Example #21
0
 /// <summary>EP message to <c>a</c>.</summary>
 /// <param name="areEqual">Constant value for <c>areEqual</c>.</param>
 /// <param name="B">Incoming message from <c>b</c>.</param>
 /// <param name="result">Modified to contain the outgoing message.</param>
 /// <returns>
 ///   <paramref name="result" />
 /// </returns>
 /// <remarks>
 ///   <para>The outgoing message is a distribution matching the moments of <c>a</c> as the random arguments are varied. The formula is <c>proj[p(a) sum_(b) p(b) factor(areEqual,a,b)]/p(a)</c>.</para>
 /// </remarks>
 public static DiscreteEnum <TEnum> AAverageConditional(bool areEqual, TEnum B, DiscreteEnum <TEnum> result)
 {
     return(DiscreteEnum <TEnum> .FromDiscrete(DiscreteAreEqualOp.AAverageConditional(areEqual, ToInt(B), result.GetInternalDiscrete())));
 }
Example #22
0
 /// <summary>Evidence message for EP.</summary>
 /// <param name="areEqual">Constant value for <c>areEqual</c>.</param>
 /// <param name="A">Incoming message from <c>a</c>.</param>
 /// <param name="B">Incoming message from <c>b</c>.</param>
 /// <returns>Logarithm of the factor's contribution the EP model evidence.</returns>
 /// <remarks>
 ///   <para>The formula for the result is <c>log(sum_(a,b) p(a,b) factor(areEqual,a,b))</c>. Adding up these values across all factors and variables gives the log-evidence estimate for EP.</para>
 /// </remarks>
 public static double LogEvidenceRatio(bool areEqual, TEnum A, TEnum B)
 {
     return(DiscreteAreEqualOp.LogEvidenceRatio(areEqual, ToInt(A), ToInt(B)));
 }
 /// <summary>
 /// EP message to 'a'
 /// </summary>
 /// <param name="areEqual">Incoming message from 'areEqual'. Must be a proper distribution.  If uniform, the result will be uniform.</param>
 /// <param name="B">Constant value for 'b'.</param>
 /// <param name="result">Modified to contain the outgoing message</param>
 /// <returns><paramref name="result"/></returns>
 /// <remarks><para>
 /// The outgoing message is a distribution matching the moments of 'a' as the random arguments are varied.
 /// The formula is <c>proj[p(a) sum_(areEqual) p(areEqual) factor(areEqual,a,b)]/p(a)</c>.
 /// </para></remarks>
 /// <exception cref="ImproperMessageException"><paramref name="areEqual"/> is not a proper distribution</exception>
 public static DiscreteEnum <TEnum> AAverageConditional([SkipIfUniform] Bernoulli areEqual, TEnum B, Discrete result)
 {
     return(new DiscreteEnum <TEnum>(DiscreteAreEqualOp.AAverageConditional(areEqual, ToInt(B), result)));
 }