当前位置: 首页>>代码示例>>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;未经允许,请勿转载。