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


C# Bernoulli.GetLogProbTrue方法代碼示例

本文整理匯總了C#中Bernoulli.GetLogProbTrue方法的典型用法代碼示例。如果您正苦於以下問題:C# Bernoulli.GetLogProbTrue方法的具體用法?C# Bernoulli.GetLogProbTrue怎麽用?C# Bernoulli.GetLogProbTrue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bernoulli的用法示例。


在下文中一共展示了Bernoulli.GetLogProbTrue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LogAverageFactor

		/// <summary>
		/// Evidence message for EP
		/// </summary>
		/// <param name="isPositive">Incoming message from 'isPositive'.</param>
		/// <param name="x">Incoming message from 'x'.</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_(isPositive,x) p(isPositive,x) factor(isPositive,x))</c>.
		/// </para></remarks>
		public static double LogAverageFactor(Bernoulli isPositive, Gaussian x)
		{
			Bernoulli to_isPositive = IsPositiveAverageConditional(x);
			return isPositive.GetLogAverageOf(to_isPositive);
#if false
			// Z = p(b=T) p(x > 0) + p(b=F) p(x <= 0)
			//   = p(b=F) + (p(b=T) - p(b=F)) p(x > 0)
			if (x.IsPointMass) {
				return Factor.IsPositive(x.Point) ? isPositive.GetLogProbTrue() : isPositive.GetLogProbFalse();
			} else if(x.IsUniform()) {
				return Bernoulli.LogProbEqual(isPositive.LogOdds,0.0);
			} else {
				// m/sqrt(v) = (m/v)/sqrt(1/v)
				double z = x.MeanTimesPrecision / Math.Sqrt(x.Precision);
				if (isPositive.IsPointMass) {
					return isPositive.Point ? MMath.NormalCdfLn(z) : MMath.NormalCdfLn(-z);
				} else {
					return MMath.LogSumExp(isPositive.GetLogProbTrue() + MMath.NormalCdfLn(z), isPositive.GetLogProbFalse() + MMath.NormalCdfLn(-z));
				}
			}
#endif
		}
開發者ID:dtrckd,項目名稱:Mixed-Membership-Stochastic-Blockmodel,代碼行數:31,代碼來源:IsPositive.cs

示例2: LogOddsAverageConditional

		/// <summary>
		/// EP message to 'logOdds'.
		/// </summary>
		/// <param name="sample">Incoming message from sample.</param>
		/// <param name="logOdds">Incoming message from 'logOdds'. Must be a proper distribution.  If uniform, the result will be uniform.</param>
		/// <returns>The outgoing EP message to the 'logOdds' argument.</returns>
		/// <remarks><para>
		/// The outgoing message is the moment matched Gaussian approximation to the factor.
		/// </para></remarks>
		public static Gaussian LogOddsAverageConditional(Bernoulli sample, [SkipIfUniform] Gaussian logOdds)
		{
			Gaussian toLogOddsT = LogOddsAverageConditional(true, logOdds);
			double logWeightT = LogAverageFactor(true, logOdds) + sample.GetLogProbTrue();
			Gaussian toLogOddsF = LogOddsAverageConditional(false, logOdds);
			double logWeightF = LogAverageFactor(false, logOdds) + sample.GetLogProbFalse();
			double maxWeight = Math.Max(logWeightT, logWeightF);
			logWeightT -= maxWeight;
			logWeightF -= maxWeight;
			Gaussian result = new Gaussian();
			result.SetToSum(Math.Exp(logWeightT), toLogOddsT * logOdds, Math.Exp(logWeightF), toLogOddsF * logOdds);
			result /= logOdds;
			return result;
		}
開發者ID:xornand,項目名稱:Infer.Net,代碼行數:23,代碼來源:BernoulliFromLogOdds.cs

示例3: LogAverageFactor

		/// <summary>
		/// Evidence message for EP.
		/// </summary>
		/// <param name="not">Constant value for 'not'.</param>
		/// <param name="b">Incoming message from 'b'.</param>
		/// <returns><c>log(int f(x) qnotf(x) dx)</c></returns>
		/// <remarks><para>
		/// The formula for the result is <c>log(int f(x) qnotf(x) dx)</c>
		/// where <c>x = (not,b)</c>.
		/// </para></remarks>
		public static double LogAverageFactor(bool not, Bernoulli b)
		{
			return not ? b.GetLogProbFalse() : b.GetLogProbTrue();
		}
開發者ID:dtrckd,項目名稱:Mixed-Membership-Stochastic-Blockmodel,代碼行數:14,代碼來源:Not.cs


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