diff --git a/src/Numerics/Distributions/Erlang.cs b/src/Numerics/Distributions/Erlang.cs index f4253cdb..ca533188 100644 --- a/src/Numerics/Distributions/Erlang.cs +++ b/src/Numerics/Distributions/Erlang.cs @@ -412,6 +412,11 @@ namespace MathNet.Numerics.Distributions return rate*Math.Exp(-rate*x); } + if (shape > 160.0) + { + return Math.Exp(PDFLn(shape, rate, x)); + } + return Math.Pow(rate, shape)*Math.Pow(x, shape - 1.0)*Math.Exp(-rate*x)/SpecialFunctions.Gamma(shape); } diff --git a/src/Numerics/Distributions/Gamma.cs b/src/Numerics/Distributions/Gamma.cs index 28eadb5a..9791daf5 100644 --- a/src/Numerics/Distributions/Gamma.cs +++ b/src/Numerics/Distributions/Gamma.cs @@ -489,6 +489,11 @@ namespace MathNet.Numerics.Distributions return rate*Math.Exp(-rate*x); } + if (shape > 160.0) + { + return Math.Exp(PDFLn(shape, rate, x)); + } + return Math.Pow(rate, shape)*Math.Pow(x, shape - 1.0)*Math.Exp(-rate*x)/SpecialFunctions.Gamma(shape); }