當前位置: 首頁>>代碼示例>>C#>>正文


C# Beta.GetMeanLogs方法代碼示例

本文整理匯總了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;
		}
開發者ID:dtrckd,項目名稱:Mixed-Membership-Stochastic-Blockmodel,代碼行數:17,代碼來源:BinomialOp.cs

示例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;
		}
開發者ID:xornand,項目名稱:Infer.Net,代碼行數:25,代碼來源:DirichletOp.cs


注:本文中的Beta.GetMeanLogs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。