Accord.Math.Special.Erfc C# (CSharp) Method

Erfc() public static method

Complementary error function of the specified value.
http://mathworld.wolfram.com/Erfc.html
public static Erfc ( double value ) : double
value double
return double
        public static double Erfc(double value)
        {
            double x, y, z, p, q;

            if (value < 0.0)
                x = -value;
            else
                x = value;

            if (x < 1.0)
                return 1.0 - Erf(value);

            z = -value * value;

            if (z < -Constants.LogMax)
            {
                if (value < 0)
                    return (2.0);
                else
                    return (0.0);
            }

            z = System.Math.Exp(z);

            if (x < 8.0)
            {
                p = Polevl(x, erfc_P, 8);
                q = P1evl(x, erfc_Q, 8);
            }
            else
            {
                p = Polevl(x, erfc_R, 5);
                q = P1evl(x, erfc_S, 6);
            }

            y = (z * p) / q;

            if (value < 0)
                y = 2.0 - y;

            if (y == 0.0)
            {
                if (value < 0)
                    return 2.0;
                else
                    return (0.0);
            }

            return y;
        }

Usage Example

コード例 #1
0
 /// <summary>
 ///   Complemented cumulative distribution function.
 /// </summary>
 ///
 /// <returns>
 ///   The area under the Gaussian p.d.f. integrated
 ///   from the given value to positive infinity.
 /// </returns>
 ///
 public static double Complemented(double value)
 {
     return(0.5 * Special.Erfc(value / Constants.Sqrt2));
 }
All Usage Examples Of Accord.Math.Special::Erfc