本文整理汇总了C#中Discrete.GetMean方法的典型用法代码示例。如果您正苦于以下问题:C# Discrete.GetMean方法的具体用法?C# Discrete.GetMean怎么用?C# Discrete.GetMean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discrete
的用法示例。
在下文中一共展示了Discrete.GetMean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PAverageLogarithm
/// <summary>
/// VMP message to 'p'
/// </summary>
/// <param name="sample">Incoming message from 'sample'.</param>
/// <param name="trialCount">Incoming message from 'trialCount'.</param>
/// <returns>The outgoing VMP message to the 'p' argument</returns>
/// <remarks><para>
/// The outgoing message is the exponential of the average log-factor value, where the average is over all arguments except 'p'.
/// The formula is <c>exp(sum_(sample,trialCount) p(sample,trialCount) log(factor(sample,trialCount,p)))</c>.
/// </para></remarks>
public static Beta PAverageLogarithm(Discrete sample, Discrete trialCount)
{
// log f(sample,n,p) = sample*log(p) + (n-sample)*log(1-p) + const.
double mSample = sample.GetMean();
return new Beta(mSample+1, trialCount.GetMean()-mSample+1);
}