Accord.Statistics.Distributions.Univariate.TDistribution.inverseDistributionLeftTail C# (CSharp) Method

inverseDistributionLeftTail() private static method

Gets the inverse of the cumulative distribution function (icdf) for the left tail T-distribution evaluated at probability p.
Based on the stdtril function from the Cephes Math Library Release 2.8, adapted with permission of Stephen L. Moshier.
private static inverseDistributionLeftTail ( double df, double p ) : double
df double
p double
return double
        private static double inverseDistributionLeftTail(double df, double p)
        {
            if (p > 0.25 && p < 0.75)
            {
                if (p == 0.5)
                    return 0;

                double u = 1.0 - 2.0 * p;
                double z = Beta.IncompleteInverse(0.5, 0.5 * df, Math.Abs(u));
                double t = Math.Sqrt(df * z / (1.0 - z));

                if (p < 0.5)
                    t = -t;

                return t;
            }
            else
            {
                int rflg = -1;

                if (p >= 0.5)
                {
                    p = 1.0 - p;
                    rflg = 1;
                }

                double z = Beta.IncompleteInverse(0.5 * df, 0.5, 2.0 * p);

                if ((Double.MaxValue * z) < df)
                    return rflg * Double.MaxValue;

                double t = Math.Sqrt(df / z - df);
                return rflg * t;
            }
        }