public void TruncatedGaussianNormaliser() { double a = 0, b = 2; var g = new TruncatedGaussian(3, 1, a, b); double Z = Quadrature.AdaptiveTrapeziumRule(x => System.Math.Exp(g.GetLogProb(x)), 32, a, b, 1e-10, 10000); Assert.True((1.0 - Z) < 1e-4); }
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="DoublePlusOp"]/message_doc[@name="LogAverageFactor(TruncatedGaussian, double, double)"]/*'/> public static double LogAverageFactor([SkipIfUniform] TruncatedGaussian sum, double a, double b) { return(sum.GetLogProb(Factor.Plus(a, b))); }
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="DoublePlusOp"]/message_doc[@name="LogAverageFactor(double, double, TruncatedGaussian)"]/*'/> public static double LogAverageFactor(double sum, double a, [SkipIfUniform] TruncatedGaussian b) { TruncatedGaussian to_sum = SumAverageConditional(a, b); return(to_sum.GetLogProb(sum)); }