本文整理匯總了C#中Beta.GetMeanLogs方法的典型用法代碼示例。如果您正苦於以下問題:C# Beta.GetMeanLogs方法的具體用法?C# Beta.GetMeanLogs怎麽用?C# Beta.GetMeanLogs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Beta
的用法示例。
在下文中一共展示了Beta.GetMeanLogs方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AverageLogFactor
/// <summary>
/// Evidence message for VMP
/// </summary>
/// <param name="sample">Constant value for 'sample'.</param>
/// <param name="p">Incoming message from 'p'.</param>
/// <param name="trialCount">Constant value for 'trialCount'.</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_(p) p(p) log(factor(sample,trialCount,p))</c>.
/// Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
/// </para></remarks>
public static double AverageLogFactor(int sample, Beta p, int trialCount)
{
double eLogP, eLogOneMinusP;
p.GetMeanLogs(out eLogP, out eLogOneMinusP);
return MMath.ChooseLn(trialCount, sample) + sample*eLogP + (trialCount-sample)*eLogOneMinusP;
}
示例2: AddAnalyticComponent
// Helper function to add the removed parts back (see note)
private static void AddAnalyticComponent(
Beta meanQ,
double ELogS,
double ES,
double ESLogS,
ref double EELogMLogGamma,
ref double EELogOneMinusMLogGamma)
{
double ELogM, ELogOneMinusM;
meanQ.GetMeanLogs(out ELogM, out ELogOneMinusM);
double ELogMSquared = ELogM * ELogM
+ MMath.Trigamma(meanQ.TrueCount) - MMath.Trigamma(meanQ.TotalCount);
EELogMLogGamma -= ELogS * ELogM + ELogMSquared;
double Em = meanQ.GetMean();
double am = meanQ.TrueCount;
double bm = meanQ.FalseCount;
double EmlogOneMinusM = Em * (MMath.Digamma(bm) - MMath.Digamma(am + bm + 1));
double EmlogmlogOneMinusM = Em * ((MMath.Digamma(bm) - MMath.Digamma(am + bm + 1)) * (MMath.Digamma(am + 1)
- MMath.Digamma(am + bm + 1)) - MMath.Trigamma(am + bm + 1));
double ELogMLogOneMinusM = ELogM * ELogOneMinusM - MMath.Trigamma(meanQ.TotalCount);
EELogOneMinusMLogGamma += .5 * Math.Log(2 * Math.PI) * ELogOneMinusM - .5 * ELogS * ELogOneMinusM
- .5 * ELogMLogOneMinusM + EmlogOneMinusM * ESLogS
+ ES * EmlogmlogOneMinusM - ES * EmlogOneMinusM;
}