本文整理汇总了C#中Beta.GetAverageLog方法的典型用法代码示例。如果您正苦于以下问题:C# Beta.GetAverageLog方法的具体用法?C# Beta.GetAverageLog怎么用?C# Beta.GetAverageLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Beta
的用法示例。
在下文中一共展示了Beta.GetAverageLog方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AverageLogFactor
/// <summary>
/// Evidence message for VMP.
/// </summary>
/// <param name="sample">Incoming message from sample</param>
/// <param name="logOdds">Incoming message from logOdds</param>
/// <returns><c>sum_x marginal(x)*log(factor(x))</c></returns>
/// <remarks><para>
/// The formula for the result is <c>int log(f(x)) q(x) dx</c>
/// where <c>x = (sample,logOdds)</c>.
/// </para></remarks>
public static double AverageLogFactor(Beta logistic, [Proper, SkipIfUniform] Gaussian x, Beta to_logistic)
{
double a = logistic.TrueCount;
double b = logistic.FalseCount;
double scale = a + b - 2;
double shift = -(b - 1);
// sigma(x) >= sigma(t) exp((x-t)/2 - a/2*(x^2 - t^2))
double m, v;
x.GetMeanAndVariance(out m, out v);
double t = Math.Sqrt(m * m + v);
double lambda = (t == 0) ? 0.25 : Math.Tanh(t / 2) / (2 * t);
double boundOnLogSigma = MMath.LogisticLn(t) + (m - t) / 2.0 - .5 * lambda * (m * m + v - t * t);
return scale * boundOnLogSigma + shift * m - logistic.GetLogNormalizer() - to_logistic.GetAverageLog(logistic);
}