From e6bbbda78a91d9cf3753e5a6ed3d867e4c8f245d Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sun, 19 Jul 2015 11:03:54 +0200 Subject: [PATCH] Distributions: Beta.PDF more robust for large distribution parameters #337 --- src/Numerics/Distributions/Beta.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Numerics/Distributions/Beta.cs b/src/Numerics/Distributions/Beta.cs index 1bf6f5f9..151df34d 100644 --- a/src/Numerics/Distributions/Beta.cs +++ b/src/Numerics/Distributions/Beta.cs @@ -545,6 +545,11 @@ namespace MathNet.Numerics.Distributions return 1.0; } + if (a > 80.0 || b > 80.0) + { + return Math.Exp(PDFLn(a, b, x)); + } + var bb = SpecialFunctions.Gamma(a + b)/(SpecialFunctions.Gamma(a)*SpecialFunctions.Gamma(b)); return bb*Math.Pow(x, a - 1.0)*Math.Pow(1.0 - x, b - 1.0); }