From e97387dc0b434064e2b78fdb611c1275152e40fd Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Fri, 26 Jul 2013 13:02:04 +0200 Subject: [PATCH] GammaRegularized: fix for large argument bug --- src/Numerics/SpecialFunctions/Gamma.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Numerics/SpecialFunctions/Gamma.cs b/src/Numerics/SpecialFunctions/Gamma.cs index 39649d55..8014ddb5 100644 --- a/src/Numerics/SpecialFunctions/Gamma.cs +++ b/src/Numerics/SpecialFunctions/Gamma.cs @@ -181,7 +181,7 @@ namespace MathNet.Numerics double ax = a * Math.Log(x) - x - GammaLn(a); if (ax < -709.78271289338399) { - return 0; + return a < x ? 0d : 1d; } ax = Math.Exp(ax); @@ -291,7 +291,7 @@ namespace MathNet.Numerics double ax = (a * Math.Log(x)) - x - GammaLn(a); if (ax < -709.78271289338399) { - return 1d; + return a < x ? 1d : 0d; } if (x <= 1 || x <= a)