Browse Source

Distributions: Erlang and Gamma PDF more robust for large shape parameter

pull/316/merge
Christoph Ruegg 11 years ago
parent
commit
d105a429e8
  1. 5
      src/Numerics/Distributions/Erlang.cs
  2. 5
      src/Numerics/Distributions/Gamma.cs

5
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);
}

5
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);
}

Loading…
Cancel
Save