Exemple #1
0
        /// <summary>
        /// This function return the cummulative distribution function (CDF)
        /// for Fisher Distribution with X from 0 to x and number degree of freedoms
        /// are k1 and k2.
        /// </summary>
        /// <param name="x">double. x</param>
        /// <param name="k1">int. k1 is firt number degree of freedom</param>
        /// <param name="k2">int. k2 is second number degree of freedom</param>
        /// <returns>
        /// The value of cummulative distribution function (CDF)
        /// for Fisher Distribution with X from 0 to x and number degree of freedoms
        /// are k1 and k2.
        /// </returns>
        public static double CDF(double x, int k1, int k2)
        {
            // number degree of freedoms and x must greater than 0
            if (!(k1 > 0 && k2 > 0 && x > 0))
            {
                return(double.NaN);
            }
            FisherFunction function = new FisherFunction(k1, k2);

            return(Integrator.GaussLegendre(function, 0, x, 1.0e-6));
        }
        /// <summary>
        /// This function return the cummulative distribution function (CDF)
        /// for ChiSquare Distribution where X2 from 0 t x2 and
        /// number degree of freedom k.
        /// </summary>
        /// <param name="x2">double. x2</param>
        /// <param name="k">int. k is number degree of freedom</param>
        /// <returns>
        /// The value of cummulative distribution function (CDF)
        /// for ChiSquare Distribution where X2 form 0 t x2 and
        /// number degree of freedom k.
        /// </returns>
        public static double CDF(double x2, int k)
        {
            // the number degree of freedom must be
            // more or equal than 1. The value of x must be
            // not less than 0
            if (k < 1 || x2 < 0)
            {
                return(double.NaN);
            }
            ChiSquareFunction function = new ChiSquareFunction(k);

            return(Integrator.GaussLegendre(function, 0, x2, 1.0e-6));
        }
Exemple #3
0
        /// <summary>
        /// This function return the cummulative distribution function (CDF)
        /// for Student's t distribution less than t and number degree of
        /// freedom k.
        /// </summary>
        /// <param name="t">double. t</param>
        /// <param name="k">int. k is number degree of freedom</param>
        /// <returns>
        /// The value of cummulative distribution function (CDF)
        /// for Student's t distribution less than t and number degree of
        /// freedom k.
        /// </returns>
        public static double CDF(double t, int k)
        {
            // number degree of freedom must be mor than 0
            if (k <= 0)
            {
                return(double.NaN);
            }
            if (t == 0)
            {
                return(0.5);
            }
            StudentFunction function = new StudentFunction(k);

            if (t < 0)
            {
                return(0.5 - Integrator.GaussLegendre(function, t, 0, 1.0e-6));
            }
            else
            {
                return(0.5 + Integrator.GaussLegendre(function, 0, t, 1.0e-6));
            }
        }
        /// <summary>
        /// Return the cumulative distribution function (CDF)
        /// for normal standard distribution with mean 0, standard
        /// deviation 1 and Z has a value less than z
        /// </summary>
        /// <param name="z">
        /// double. z is standard value where Z ~ N(0, 1)
        /// </param>
        /// <returns>
        /// The cumulative distribution function for normal
        /// standard distribution has a value less then z
        /// </returns>
        public static double CDF(double z)
        {
            // The CDF value for z < -10 --> 0
            if (z < -10.0)
            {
                return(double.Epsilon);
            }
            // The CDF value for z > 10 --> 1
            if (z > 10.0)
            {
                return(1.0 - double.Epsilon);
            }
            NormalFunction function = new NormalFunction(0.0, 1.0);

            // accuracy of the integration method is 1.0e-6
            if (z < 0)
            {
                return(0.5 - Integrator.GaussLegendre(function, z, 0, 1.0e-6));
            }
            else
            {
                return(0.5 + Integrator.GaussLegendre(function, 0, z, 1.0e-6));
            }
        }