本文整理汇总了C#中Gaussian.GetLogAverageOf方法的典型用法代码示例。如果您正苦于以下问题:C# Gaussian.GetLogAverageOf方法的具体用法?C# Gaussian.GetLogAverageOf怎么用?C# Gaussian.GetLogAverageOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gaussian
的用法示例。
在下文中一共展示了Gaussian.GetLogAverageOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeStats
// logw1 = N(mx;m1,vx+v1) phi((mx1 - m2)/sqrt(vx1+v2))
// a1 = N(mx1;m2,vx1+v2)/phi
internal static void ComputeStats(Gaussian max, Gaussian a, Gaussian b, out double logz,
out double logw1, out double a1, out double vx1, out double mx1,
out double logw2, out double a2, out double vx2, out double mx2)
{
double m1, v1, m2, v2;
a.GetMeanAndVariance(out m1, out v1);
b.GetMeanAndVariance(out m2, out v2);
if (max.IsPointMass) {
vx1 = 0.0;
mx1 = max.Point;
vx2 = 0.0;
mx2 = max.Point;
if (b.IsPointMass) {
if (b.Point > max.Point) throw new AllZeroException();
else if (b.Point == max.Point) {
// the factor reduces to the constraint (max.Point > a)
logw1 = Double.NegativeInfinity;
logw2 = MMath.NormalCdfLn((max.Point - m1)/Math.Sqrt(v1));
logz = logw2;
a1 = 0;
a2 = Math.Exp(Gaussian.GetLogProb(max.Point, m1, v1) - logw2);
return;
} else {
// b.Point < max.Point
// the factor reduces to the constraint (a == max.Point)
throw new NotImplementedException();
}
} else if (a.IsPointMass) throw new NotImplementedException();
} else {
if (a.IsPointMass) {
vx1 = 0.0;
mx1 = a.Point;
} else {
vx1 = 1.0 / (max.Precision + a.Precision);
mx1 = vx1 * (max.MeanTimesPrecision + a.MeanTimesPrecision);
}
if (b.IsPointMass) {
vx2 = 0.0;
mx2 = b.Point;
} else {
vx2 = 1.0 / (max.Precision + b.Precision);
mx2 = vx2 * (max.MeanTimesPrecision + b.MeanTimesPrecision);
}
}
logw1 = max.GetLogAverageOf(a);
double logPhi1 = MMath.NormalCdfLn((mx1 - m2) / Math.Sqrt(vx1 + v2));
logw1 += logPhi1;
logw2 = max.GetLogAverageOf(b);
double logPhi2 = MMath.NormalCdfLn((mx2 - m1) / Math.Sqrt(vx2 + v1));
logw2 += logPhi2;
logz = MMath.LogSumExp(logw1, logw2);
double logN1 = Gaussian.GetLogProb(mx1, m2, vx1 + v2);
a1 = Math.Exp(logN1 - logPhi1);
double logN2 = Gaussian.GetLogProb(mx2, m1, vx2 + v1);
a2 = Math.Exp(logN2 - logPhi2);
}
示例2: LogEvidenceRatio
public static double LogEvidenceRatio([SkipIfUniform] Gaussian Product, [SkipIfUniform] Gaussian A, [SkipIfUniform] Gaussian B, Gaussian to_A, Gaussian to_product)
{
return LogAverageFactor(Product, A, B, to_A) - to_product.GetLogAverageOf(Product);
}
示例3: LogEvidenceRatio
public static double LogEvidenceRatio(Gaussian sample, Gaussian mean, Gamma variance, Gaussian to_sample)
{
return LogAverageFactor(sample, mean, variance) - to_sample.GetLogAverageOf(sample);
}