From fe0e680f4bc8af96054da1a0d167658e60742a16 Mon Sep 17 00:00:00 2001 From: mikael Date: Sat, 2 Nov 2019 15:10:19 +0100 Subject: [PATCH] Use specialzied distributions depending on param values in InvCDF --- src/Numerics/Distributions/SkewedGeneralizedT.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Numerics/Distributions/SkewedGeneralizedT.cs b/src/Numerics/Distributions/SkewedGeneralizedT.cs index 720cdeec..4fb35041 100644 --- a/src/Numerics/Distributions/SkewedGeneralizedT.cs +++ b/src/Numerics/Distributions/SkewedGeneralizedT.cs @@ -408,6 +408,18 @@ namespace MathNet.Numerics.Distributions throw new ArgumentException(Resources.InvalidDistributionParameters); } + // If parameters represent a specialized distribution, then we use that distribution to avoid + // problems with infinite p or q parameters. + var d = FindSpecializedDistribution(location, scale, skew, p, q); + // InverseCumulativeDistribution is not a part of the interface, so resort to type-checking. + if (d != null) + { + if (d is SkewedGeneralizedError sge) + return sge.InverseCumulativeDistribution(pr); + if (d is ContinuousUniform u) + return u.InverseCumulativeDistribution(pr); + } + // Note: Adapted from the R package, // solving for the inverse of the CDF that uses the inverse of the incomplete beta function or // incomplete gamma function