public static VectorGaussianWishart ShapeParamsAverageConditional( Vector point, Bernoulli label, [Proper] VectorGaussianWishart shapeParams, VectorGaussianWishart result) { VectorGaussianWishart shapeParamsTimesFactor = DistributionTimesFactor(point, shapeParams); double labelProbFalse = label.GetProbFalse(); double shapeParamsWeight = labelProbFalse; double shapeParamsTimesFactorWeight = Math.Exp(shapeParamsTimesFactor.GetLogNormalizer() - shapeParams.GetLogNormalizer()) * (1 - 2 * labelProbFalse); var projectionOfSum = new VectorGaussianWishart(2); projectionOfSum.SetToSum(shapeParamsWeight, shapeParams, shapeParamsTimesFactorWeight, shapeParamsTimesFactor); Debug.Assert(projectionOfSum.IsProper()); // TODO: remove me result.SetToRatio(projectionOfSum, shapeParams); return result; }