当前位置: 首页>>代码示例>>C#>>正文


C# Gaussian.GetLogNormalizer方法代码示例

本文整理汇总了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);
 }
开发者ID:hr0nix,项目名称:BayesianShapePrior,代码行数:12,代码来源:ShapeFactors.cs

示例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();
            }
        }
开发者ID:hr0nix,项目名称:BayesianShapePrior,代码行数:53,代码来源:ShapeFactors.cs

示例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();
     }
 }
开发者ID:hr0nix,项目名称:BayesianShapePrior,代码行数:24,代码来源:ShapeFactors.cs


注:本文中的Gaussian.GetLogNormalizer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。