Esempio n. 1
0
 /// <summary>Evidence message for EP.</summary>
 /// <param name="Int">Constant value for <c>Int</c>.</param>
 /// <param name="Enum">Incoming message from <c>Enum</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_(Enum) p(Enum) factor(Int,Enum))</c>.</para>
 /// </remarks>
 public static double LogAverageFactor(int Int, TEnum Enum)
 {
     return((EnumSupport.EnumToInt(Enum) == Int) ? 0.0 : Double.NegativeInfinity);
 }
Esempio n. 2
0
 /// <summary>VMP message to <c>Probs</c>.</summary>
 /// <param name="sample">Incoming message from <c>Sample</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>Probs</c>. The formula is <c>exp(sum_(Sample) p(Sample) log(factor(Sample,Probs)))</c>.</para>
 /// </remarks>
 public static Dirichlet ProbsAverageLogarithm(TEnum sample, Dirichlet result)
 {
     return(DiscreteFromDirichletOp.ProbsAverageLogarithm(EnumSupport.EnumToInt(sample), result));
 }
Esempio n. 3
0
 /// <summary>EP message to <c>Probs</c>.</summary>
 /// <param name="sample">Incoming message from <c>Sample</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>Probs</c> as the random arguments are varied. The formula is <c>proj[p(Probs) sum_(Sample) p(Sample) factor(Sample,Probs)]/p(Probs)</c>.</para>
 /// </remarks>
 public static Dirichlet ProbsAverageConditional(TEnum sample, Dirichlet result)
 {
     return(DiscreteFromDirichletOp.ProbsAverageConditional(EnumSupport.EnumToInt(sample), result));
 }
Esempio n. 4
0
 /// <summary>Evidence message for EP.</summary>
 /// <param name="sample">Incoming message from <c>Sample</c>.</param>
 /// <param name="probs">Constant value for <c>Probs</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_(Sample) p(Sample) factor(Sample,Probs) / sum_Sample p(Sample) messageTo(Sample))</c>. Adding up these values across all factors and variables gives the log-evidence estimate for EP.</para>
 /// </remarks>
 public static double LogEvidenceRatio(TEnum sample, Vector probs)
 {
     return(DiscreteFromDirichletOp.LogEvidenceRatio(EnumSupport.EnumToInt(sample), probs));
 }
Esempio n. 5
0
 /// <summary>Evidence message for VMP.</summary>
 /// <param name="sample">Incoming message from <c>Sample</c>.</param>
 /// <param name="probs">Constant value for <c>Probs</c>.</param>
 /// <returns>Average of the factor's log-value across the given argument distributions.</returns>
 /// <remarks>
 ///   <para>The formula for the result is <c>sum_(Sample) p(Sample) log(factor(Sample,Probs))</c>. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.</para>
 /// </remarks>
 public static double AverageLogFactor(TEnum sample, Vector probs)
 {
     return(DiscreteFromDirichletOp.AverageLogFactor(EnumSupport.EnumToInt(sample), probs));
 }
 /// <summary>
 /// Evidence message for EP
 /// </summary>
 /// <param name="Int">Incoming message from 'Int'.</param>
 /// <param name="Enum">Constant value for 'Enum'.</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_(Int) p(Int) factor(Int,Enum))</c>.
 /// </para></remarks>
 public static double LogAverageFactor(Discrete Int, TEnum Enum)
 {
     return(Int.GetLogProb(EnumSupport.EnumToInt(Enum)));
 }