本文整理汇总了C#中Gaussian.GetLogNormalizer方法的典型用法代码示例。如果您正苦于以下问题:C# Gaussian.GetLogNormalizer方法的具体用法?C# Gaussian.GetLogNormalizer怎么用?C# Gaussian.GetLogNormalizer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gaussian
的用法示例。
在下文中一共展示了Gaussian.GetLogNormalizer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogAverageFactor
public static double LogAverageFactor(
Bernoulli label, Vector point, Gaussian shapeX, Gaussian shapeY, PositiveDefiniteMatrix shapeOrientation)
{
VectorGaussian shapeLocationTimesFactor = ShapeLocationTimesFactor(point, shapeX, shapeY, shapeOrientation);
double labelProbFalse = label.GetProbFalse();
double normalizerProduct = Math.Exp(
shapeLocationTimesFactor.GetLogNormalizer() - 0.5 * shapeOrientation.QuadraticForm(point)
- shapeX.GetLogNormalizer() - shapeY.GetLogNormalizer());
double averageFactor = labelProbFalse + (1 - 2 * labelProbFalse) * normalizerProduct;
Debug.Assert(averageFactor > 0);
return Math.Log(averageFactor);
}
示例2: ShapeAverageConditional
private static Gaussian ShapeAverageConditional(
Vector point, Bernoulli label, Gaussian shapeX, Gaussian shapeY, PositiveDefiniteMatrix shapeOrientation, bool resultForXCoord)
{
if (shapeX.IsPointMass && shapeY.IsPointMass)
{
double labelProbTrue = label.GetProbTrue();
double labelProbFalse = 1.0 - labelProbTrue;
double probDiff = labelProbTrue - labelProbFalse;
Vector shapeLocation = Vector.FromArray(shapeX.Point, shapeY.Point);
Vector diff = point - shapeLocation;
Vector orientationTimesDiff = shapeOrientation * diff;
Matrix orientationTimesDiffOuter = orientationTimesDiff.Outer(orientationTimesDiff);
double factorValue = Math.Exp(-0.5 * shapeOrientation.QuadraticForm(diff));
double funcValue = factorValue * probDiff + labelProbFalse;
Vector dFunc = probDiff * factorValue * orientationTimesDiff;
Vector dLogFunc = 1.0 / funcValue * dFunc;
Matrix ddLogFunc =
((orientationTimesDiffOuter + shapeOrientation) * factorValue * funcValue - orientationTimesDiffOuter * probDiff * factorValue * factorValue)
* (probDiff / (funcValue * funcValue));
double x = resultForXCoord ? shapeX.Point : shapeY.Point;
double d = resultForXCoord ? dLogFunc[0] : dLogFunc[1];
double dd = resultForXCoord ? ddLogFunc[0, 0] : ddLogFunc[1, 1];
return Gaussian.FromDerivatives(x, d, dd, forceProper: true);
}
else if (!shapeX.IsPointMass && !shapeY.IsPointMass)
{
VectorGaussian shapeLocationTimesFactor = ShapeLocationTimesFactor(point, shapeX, shapeY, shapeOrientation);
double labelProbFalse = label.GetProbFalse();
double shapeLocationWeight = labelProbFalse;
double shapeLocationTimesFactorWeight =
Math.Exp(shapeLocationTimesFactor.GetLogNormalizer() - shapeX.GetLogNormalizer() - shapeY.GetLogNormalizer() - 0.5 * shapeOrientation.QuadraticForm(point)) *
(1 - 2 * labelProbFalse);
var projectionOfSum = new Gaussian();
projectionOfSum.SetToSum(
shapeLocationWeight,
resultForXCoord ? shapeX : shapeY,
shapeLocationTimesFactorWeight,
shapeLocationTimesFactor.GetMarginal(resultForXCoord ? 0 : 1));
Gaussian result = new Gaussian();
result.SetToRatio(projectionOfSum, resultForXCoord ? shapeX : shapeY);
return result;
}
else
{
throw new NotSupportedException();
}
}
示例3: LabelAverageConditional
public static Bernoulli LabelAverageConditional(
Vector point, Gaussian shapeX, Gaussian shapeY, Wishart shapeOrientation)
{
if (shapeOrientation.IsPointMass)
{
if (shapeX.IsPointMass && shapeY.IsPointMass)
{
return LabelAverageConditional(point, shapeX.Point, shapeY.Point, shapeOrientation.Point);
}
else if (!shapeX.IsPointMass && !shapeY.IsPointMass)
{
VectorGaussian shapeLocationTimesFactor = ShapeLocationTimesFactor(point, shapeX, shapeY, shapeOrientation.Point);
return new Bernoulli(Math.Exp(shapeLocationTimesFactor.GetLogNormalizer() - shapeX.GetLogNormalizer() - shapeY.GetLogNormalizer() - 0.5 * shapeOrientation.Point.QuadraticForm(point)));
}
else
{
throw new NotSupportedException();
}
}
else
{
throw new NotSupportedException();
}
}