/// <summary>
        /// Run example
        /// </summary>
        /// <seealso cref="http://en.wikipedia.org/wiki/Factorial">Factorial</seealso>
        /// <seealso cref="http://en.wikipedia.org/wiki/Binomial_coefficient">Binomial coefficient</seealso>
        /// <seealso cref="http://en.wikipedia.org/wiki/Multinomial_theorem#Multinomial_coefficients">Multinomial coefficients</seealso>
        public void Run()
        {
            // 1. Compute the factorial of 5
            Console.WriteLine(@"1. Compute the factorial of 5");
            Console.WriteLine(SpecialFunctions.Factorial(5).ToString("N"));
            Console.WriteLine();

            // 2. Compute the logarithm of the factorial of 5
            Console.WriteLine(@"2. Compute the logarithm of the factorial of 5");
            Console.WriteLine(SpecialFunctions.FactorialLn(5).ToString("N"));
            Console.WriteLine();

            // 3. Compute the binomial coefficient: 10 choose 8
            Console.WriteLine(@"3. Compute the binomial coefficient: 10 choose 8");
            Console.WriteLine(SpecialFunctions.Binomial(10, 8).ToString("N"));
            Console.WriteLine();

            // 4. Compute the logarithm of the binomial coefficient: 10 choose 8
            Console.WriteLine(@"4. Compute the logarithm of the binomial coefficient: 10 choose 8");
            Console.WriteLine(SpecialFunctions.BinomialLn(10, 8).ToString("N"));
            Console.WriteLine();

            // 5. Compute the multinomial coefficient: 10 choose 2, 3, 5
            Console.WriteLine(@"5. Compute the multinomial coefficient: 10 choose 2, 3, 5");
            Console.WriteLine(SpecialFunctions.Multinomial(10, new[] { 2, 3, 5 }).ToString("N"));
            Console.WriteLine();
        }
Beispiel #2
0
        /// <summary>
        /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X ≤ x).
        /// </summary>
        /// <param name="x">The location at which to compute the cumulative distribution function.</param>
        /// <param name="population">The size of the population (N).</param>
        /// <param name="success">The number successes within the population (K, M).</param>
        /// <param name="draws">The number of draws without replacement (n).</param>
        /// <returns>the cumulative distribution at location <paramref name="x"/>.</returns>
        /// <seealso cref="CumulativeDistribution"/>
        public static double CDF(int population, int success, int draws, double x)
        {
            if (!(population >= 0 && success >= 0 && draws >= 0 && success <= population && draws <= population))
            {
                throw new ArgumentException(Resources.InvalidDistributionParameters);
            }

            if (x < System.Math.Max(0, draws + success - population))
            {
                return(0.0);
            }

            if (x >= System.Math.Min(success, draws))
            {
                return(1.0);
            }

            var k             = (int)System.Math.Floor(x);
            var denominatorLn = SpecialFunctions.BinomialLn(population, draws);
            var sum           = 0.0;

            for (var i = 0; i <= k; i++)
            {
                sum += System.Math.Exp(SpecialFunctions.BinomialLn(success, i) + SpecialFunctions.BinomialLn(population - success, draws - i) - denominatorLn);
            }

            return(sum);
        }
Beispiel #3
0
        /// <summary>
        /// Computes values of the log probability mass function.
        /// </summary>
        /// <param name="k">The location in the domain where we want to evaluate the log probability mass function.</param>
        /// <returns>the log probability mass at location <paramref name="k"/>.</returns>
        public double ProbabilityLn(int k)
        {
            if (k < 0)
            {
                return(Double.NegativeInfinity);
            }

            if (k > _n)
            {
                return(Double.NegativeInfinity);
            }

            if (_p == 0.0 && k == 0)
            {
                return(0.0);
            }

            if (_p == 0.0)
            {
                return(Double.NegativeInfinity);
            }

            if (_p == 1.0 && k == _n)
            {
                return(0.0);
            }

            if (_p == 1.0)
            {
                return(Double.NegativeInfinity);
            }

            return(SpecialFunctions.BinomialLn(_n, k) + (k * Math.Log(_p)) + ((_n - k) * Math.Log(1.0 - _p)));
        }
Beispiel #4
0
        /// <summary>
        /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
        /// </summary>
        /// <param name="k">The location in the domain where we want to evaluate the log probability mass function.</param>
        /// <param name="population">The size of the population (N).</param>
        /// <param name="success">The number successes within the population (K, M).</param>
        /// <param name="draws">The number of draws without replacement (n).</param>
        /// <returns>the log probability mass at location <paramref name="k"/>.</returns>
        public static double PMFLn(int population, int success, int draws, int k)
        {
            if (!(population >= 0 && success >= 0 && draws >= 0 && success <= population && draws <= population))
            {
                throw new ArgumentException(Resources.InvalidDistributionParameters);
            }

            return(SpecialFunctions.BinomialLn(success, k) + SpecialFunctions.BinomialLn(population - success, draws - k) - SpecialFunctions.BinomialLn(population, draws));
        }
Beispiel #5
0
        /// <summary>
        /// Ported from Fortran
        /// Modifies pExcd
        /// </summary>
        /// <param name="nPerm"></param>
        /// <param name="n1s"></param>
        /// <param name="sbdry"></param>
        /// <param name="sbdryOffset"></param>
        /// <param name="pExcd"></param>
        private static void PExceed(uint nPerm, uint n1s, uint[] sbdry, uint sbdryOffset,
                                    out double pExcd)
        {
            double dlcnk;
            int    i, n, k, n1, k1, n2, k2, n3, k3;

            n     = Convert.ToInt32(nPerm);
            k     = Convert.ToInt32(n1s);
            n1    = Convert.ToInt32(nPerm - sbdry[sbdryOffset]);
            dlcnk = SpecialFunctions.BinomialLn(n, k);
            pExcd = Math.Exp(
                SpecialFunctions.BinomialLn(n1, k) - dlcnk);
            if (n1s >= 2)
            {
                n1     = Convert.ToInt32(sbdry[sbdryOffset]);
                n      = Convert.ToInt32(nPerm - sbdry[sbdryOffset + 1]);
                k      = Convert.ToInt32(n1s - 1);
                pExcd += Math.Exp(Math.Log(n1) + SpecialFunctions.BinomialLn(n, k) -
                                  dlcnk);
            }
            if (n1s >= 3)
            {
                n1     = Convert.ToInt32(sbdry[sbdryOffset]);
                n2     = Convert.ToInt32(sbdry[sbdryOffset + 1]);
                n      = Convert.ToInt32(nPerm - sbdry[sbdryOffset + 2]);
                k      = Convert.ToInt32(n1s - 2);
                pExcd += Math.Exp(Math.Log(n1) + Math.Log(n1 - 1.0) - Math.Log(2.0) +
                                  SpecialFunctions.BinomialLn(n, k) - dlcnk) +
                         Math.Exp(Math.Log(n1) + Math.Log(n2 - n1) +
                                  SpecialFunctions.BinomialLn(n, k) - dlcnk);
            }
            if (n1s > 3)
            {
                for (i = 4; i <= n1s; i++)
                {
                    n1     = Convert.ToInt32(sbdry[sbdryOffset + i - 4]);
                    k1     = i - 1;
                    k2     = i - 2;
                    k3     = i - 3;
                    n2     = Convert.ToInt32(sbdry[sbdryOffset + i - 3]);
                    n3     = Convert.ToInt32(sbdry[sbdryOffset + i - 2]);
                    n      = Convert.ToInt32(nPerm - sbdry[sbdryOffset + i - 1]);
                    k      = Convert.ToInt32(n1s - i + 1);
                    pExcd += Math.Exp(SpecialFunctions.BinomialLn(n1, k1) +
                                      SpecialFunctions.BinomialLn(n, k) - dlcnk) +
                             Math.Exp(SpecialFunctions.BinomialLn(n1, k2) +
                                      Math.Log(n3 - n1) +
                                      SpecialFunctions.BinomialLn(n, k) - dlcnk) +
                             Math.Exp(SpecialFunctions.BinomialLn(n1, k3) +
                                      Math.Log(n2 - n1) + Math.Log(n3 - n2) +
                                      SpecialFunctions.BinomialLn(n, k) - dlcnk) +
                             Math.Exp(SpecialFunctions.BinomialLn(n1, k3) +
                                      Math.Log(n2 - n1) - Math.Log(2.0) + Math.Log(n2 - n1 - 1.0) +
                                      SpecialFunctions.BinomialLn(n, k) - dlcnk);
                }
            }
        }
 public void CanComputeBinomialLn()
 {
     AssertHelpers.AlmostEqualRelative(Math.Log(1), SpecialFunctions.BinomialLn(1, 1), 14);
     AssertHelpers.AlmostEqualRelative(Math.Log(10), SpecialFunctions.BinomialLn(5, 2), 14);
     AssertHelpers.AlmostEqualRelative(Math.Log(35), SpecialFunctions.BinomialLn(7, 3), 14);
     AssertHelpers.AlmostEqualRelative(Math.Log(1), SpecialFunctions.BinomialLn(1, 0), 14);
     AssertHelpers.AlmostEqualRelative(Math.Log(0), SpecialFunctions.BinomialLn(0, 1), 14);
     AssertHelpers.AlmostEqualRelative(Math.Log(0), SpecialFunctions.BinomialLn(5, 7), 14);
     AssertHelpers.AlmostEqualRelative(Math.Log(0), SpecialFunctions.BinomialLn(5, -7), 14);
 }
Beispiel #7
0
 /// <summary>
 /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
 /// </summary>
 /// <param name="k">The location in the domain where we want to evaluate the log probability mass function.</param>
 /// <param name="p">The success probability (p) in each trial. Range: 0 ≤ p ≤ 1.</param>
 /// <param name="n">The number of trials (n). Range: n ≥ 0.</param>
 /// <returns>the log probability mass at location <paramref name="k"/>.</returns>
 public static double PMFLn(double p, int n, int k)
 {
     if (!(p >= 0.0 && p <= 1.0 && n >= 0))
     {
         throw new ArgumentException(Resources.InvalidDistributionParameters);
     }
     if (k < 0 || k > n)
     {
         return(Double.NegativeInfinity);
     }
     if (p == 0.0)
     {
         return(k == 0 ? 0.0 : Double.NegativeInfinity);
     }
     if (p == 1.0)
     {
         return(k == n ? 0.0 : Double.NegativeInfinity);
     }
     return(SpecialFunctions.BinomialLn(n, k) + (k * Math.Log(p)) + ((n - k) * Math.Log(1.0 - p)));
 }
        /// <summary>
        /// Computes the cumulative distribution function (CDF) of the distribution, i.e. P(X &lt;= x).
        /// </summary>
        /// <param name="x">The location at which to compute the cumulative density.</param>
        /// <returns>the cumulative density at <paramref name="x"/>.</returns>
        public double CumulativeDistribution(double x)
        {
            if (x < Minimum)
            {
                return 0.0;
            }
            if (x >= Maximum)
            {
                return 1.0;
            }

            var k = (int) Math.Floor(x);
            var denominatorLn = SpecialFunctions.BinomialLn(_population, _draws);
            var sum = 0.0;
            for (var i = 0; i <= k; i++)
            {
                sum += Math.Exp(SpecialFunctions.BinomialLn(_success, i) + SpecialFunctions.BinomialLn(_population - _success, _draws - i) - denominatorLn);
            }
            return sum;
        }
Beispiel #9
0
        /// <summary>
        /// Computes the probability mass (PMF) at k, i.e. P(X = k).
        /// </summary>
        /// <param name="k">The location in the domain where we want to evaluate the probability mass function.</param>
        /// <param name="p">The success probability (p) in each trial. Range: 0 ≤ p ≤ 1.</param>
        /// <param name="n">The number of trials (n). Range: n ≥ 0.</param>
        /// <returns>the probability mass at location <paramref name="k"/>.</returns>
        public static double PMF(double p, int n, int k)
        {
            //if (!(p >= 0.0 && p <= 1.0 && n >= 0)) {
            //    throw new ArgumentException("InvalidDistributionParameters");
            //}

            if (k < 0 || k > n)
            {
                return(0.0);
            }

            if (p == 0.0)
            {
                return(k == 0 ? 1.0 : 0.0);
            }

            if (p == 1.0)
            {
                return(k == n ? 1.0 : 0.0);
            }

            return(Math.Exp(SpecialFunctions.BinomialLn(n, k) + (k * Math.Log(p)) + ((n - k) * Math.Log(1.0 - p))));
        }
Beispiel #10
0
 /// <summary>
 /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
 /// </summary>
 /// <param name="k">The location in the domain where we want to evaluate the log probability mass function.</param>
 /// <returns>the log probability mass at location <paramref name="k"/>.</returns>
 public double ProbabilityLn(int k)
 {
     return(SpecialFunctions.BinomialLn(_success, k) + SpecialFunctions.BinomialLn(_population - _success, _draws - k) - SpecialFunctions.BinomialLn(_population, _draws));
 }
Beispiel #11
0
        /// <summary>
        /// Executes the example.
        /// </summary>
        public override void ExecuteExample()
        {
            // <seealso cref="http://en.wikipedia.org/wiki/Beta_function">Beta function</seealso>
            MathDisplay.WriteLine("<b>Beta fuction</b>");

            // 1. Compute the Beta function at z = 1.0, w = 3.0
            MathDisplay.WriteLine(@"1. Compute the Beta function at z = 1.0, w = 3.0");
            MathDisplay.WriteLine(SpecialFunctions.Beta(1.0, 3.0).ToString());
            MathDisplay.WriteLine();

            // 2. Compute the logarithm of the Beta function at z = 1.0, w = 3.0
            MathDisplay.WriteLine(@"2. Compute the logarithm of the Beta function at z = 1.0, w = 3.0");
            MathDisplay.WriteLine(SpecialFunctions.BetaLn(1.0, 3.0).ToString());
            MathDisplay.WriteLine();

            // 3. Compute the Beta incomplete function at z = 1.0, w = 3.0, x = 0.7
            MathDisplay.WriteLine(@"3. Compute the Beta incomplete function at z = 1.0, w = 3.0, x = 0.7");
            MathDisplay.WriteLine(SpecialFunctions.BetaIncomplete(1.0, 3.0, 0.7).ToString());
            MathDisplay.WriteLine();

            // 4. Compute the Beta incomplete function at z = 1.0, w = 3.0, x = 1.0
            MathDisplay.WriteLine(@"4. Compute the Beta incomplete function at z = 1.0, w = 3.0, x = 1.0");
            MathDisplay.WriteLine(SpecialFunctions.BetaIncomplete(1.0, 3.0, 1.0).ToString());
            MathDisplay.WriteLine();

            // 5. Compute the Beta regularized function at z = 1.0, w = 3.0, x = 0.7
            MathDisplay.WriteLine(@"5. Compute the Beta regularized function at z = 1.0, w = 3.0, x = 0.7");
            MathDisplay.WriteLine(SpecialFunctions.BetaRegularized(1.0, 3.0, 0.7).ToString());
            MathDisplay.WriteLine();

            // 6. Compute the Beta regularized  function at z = 1.0, w = 3.0, x = 1.0
            MathDisplay.WriteLine(@"6. Compute the Beta regularized function at z = 1.0, w = 3.0, x = 1.0");
            MathDisplay.WriteLine(SpecialFunctions.BetaRegularized(1.0, 3.0, 1.0).ToString());
            MathDisplay.WriteLine();



            MathDisplay.WriteLine("<b>Common functions</b>");

            // 1. Calculate the Digamma function at point 5.0
            // <seealso cref="http://en.wikipedia.org/wiki/Digamma_function">Digamma function</seealso>
            MathDisplay.WriteLine(@"1. Calculate the Digamma function at point 5.0");
            MathDisplay.WriteLine(SpecialFunctions.DiGamma(5.0).ToString());
            MathDisplay.WriteLine();

            // 2. Calculate the inverse Digamma function at point 1.5
            MathDisplay.WriteLine(@"2. Calculate the inverse Digamma function at point 1.5");
            MathDisplay.WriteLine(SpecialFunctions.DiGammaInv(1.5).ToString());
            MathDisplay.WriteLine();

            // 3. Calculate the 10'th Harmonic number
            // <seealso cref="http://en.wikipedia.org/wiki/Harmonic_number">Harmonic number</seealso>
            MathDisplay.WriteLine(@"3. Calculate the 10'th Harmonic number");
            MathDisplay.WriteLine(SpecialFunctions.Harmonic(10).ToString());
            MathDisplay.WriteLine();

            // 4. Calculate the generalized harmonic number of order 10 of 3.0.
            // <seealso cref="http://en.wikipedia.org/wiki/Harmonic_number#Generalized_harmonic_numbers">Generalized harmonic numbers</seealso>
            MathDisplay.WriteLine(@"4. Calculate the generalized harmonic number of order 10 of 3.0");
            MathDisplay.WriteLine(SpecialFunctions.GeneralHarmonic(10, 3.0).ToString());
            MathDisplay.WriteLine();

            // 5. Calculate the logistic function of 3.0
            // <seealso cref="http://en.wikipedia.org/wiki/Logistic_function">Logistic function</seealso>
            MathDisplay.WriteLine(@"5. Calculate the logistic function of 3.0");
            MathDisplay.WriteLine(SpecialFunctions.Logistic(3.0).ToString());
            MathDisplay.WriteLine();

            // 6. Calculate the logit function of 0.3
            // <seealso cref="http://en.wikipedia.org/wiki/Logit">Logit function</seealso>
            MathDisplay.WriteLine(@"6. Calculate the logit function of 0.3");
            MathDisplay.WriteLine(SpecialFunctions.Logit(0.3).ToString());
            MathDisplay.WriteLine();

            // <seealso cref="http://en.wikipedia.org/wiki/Error_function">Error function</seealso>
            MathDisplay.WriteLine("<b>Error function</b>");

            // 1. Calculate the error function at point 2
            MathDisplay.WriteLine(@"1. Calculate the error function at point 2");
            MathDisplay.WriteLine(SpecialFunctions.Erf(2).ToString());
            MathDisplay.WriteLine();

            // 2. Sample 10 values of the error function in [-1.0; 1.0]
            MathDisplay.WriteLine(@"2. Sample 10 values of the error function in [-1.0; 1.0]");
            var data = Generate.LinearSpacedMap <double>(10, -1.0, 1.0, SpecialFunctions.Erf);

            for (var i = 0; i < data.Length; i++)
            {
                MathDisplay.Write(data[i].ToString("N") + @" ");
            }

            MathDisplay.WriteLine();
            MathDisplay.WriteLine();

            // 3. Calculate the complementary error function at point 2
            MathDisplay.WriteLine(@"3. Calculate the complementary error function at point 2");
            MathDisplay.WriteLine(SpecialFunctions.Erfc(2).ToString());
            MathDisplay.WriteLine();

            // 4. Sample 10 values of the complementary error function in [-1.0; 1.0]
            MathDisplay.WriteLine(@"4. Sample 10 values of the complementary error function in [-1.0; 1.0]");
            data = Generate.LinearSpacedMap <double>(10, -1.0, 1.0, SpecialFunctions.Erfc);
            for (var i = 0; i < data.Length; i++)
            {
                MathDisplay.Write(data[i].ToString("N") + @" ");
            }

            MathDisplay.WriteLine();
            MathDisplay.WriteLine();

            // 5. Calculate the inverse error function at point z=0.5
            MathDisplay.WriteLine(@"5. Calculate the inverse error function at point z=0.5");
            MathDisplay.WriteLine(SpecialFunctions.ErfInv(0.5).ToString());
            MathDisplay.WriteLine();

            // 6. Sample 10 values of the inverse error function in [-1.0; 1.0]
            MathDisplay.WriteLine(@"6. Sample 10 values of the inverse error function in [-1.0; 1.0]");
            data = Generate.LinearSpacedMap <double>(10, -1.0, 1.0, SpecialFunctions.ErfInv);
            for (var i = 0; i < data.Length; i++)
            {
                MathDisplay.Write(data[i].ToString("N") + @" ");
            }

            MathDisplay.WriteLine();
            MathDisplay.WriteLine();

            // 7. Calculate the complementary inverse error function at point z=0.5
            MathDisplay.WriteLine(@"7. Calculate the complementary inverse error function at point z=0.5");
            MathDisplay.WriteLine(SpecialFunctions.ErfcInv(0.5).ToString());
            MathDisplay.WriteLine();

            // 8. Sample 10 values of the complementary inverse error function in [-1.0; 1.0]
            MathDisplay.WriteLine(@"8. Sample 10 values of the complementary inverse error function in [-1.0; 1.0]");
            data = Generate.LinearSpacedMap <double>(10, -1.0, 1.0, SpecialFunctions.ErfcInv);
            for (var i = 0; i < data.Length; i++)
            {
                MathDisplay.Write(data[i].ToString("N") + @" ");
            }

            MathDisplay.WriteLine();


            // <seealso cref="http://en.wikipedia.org/wiki/Factorial">Factorial</seealso>
            MathDisplay.WriteLine("<b>Factorial</b>");

            // 1. Compute the factorial of 5
            MathDisplay.WriteLine(@"1. Compute the factorial of 5");
            MathDisplay.WriteLine(SpecialFunctions.Factorial(5).ToString("N"));
            MathDisplay.WriteLine();

            // 2. Compute the logarithm of the factorial of 5
            MathDisplay.WriteLine(@"2. Compute the logarithm of the factorial of 5");
            MathDisplay.WriteLine(SpecialFunctions.FactorialLn(5).ToString("N"));
            MathDisplay.WriteLine();


            // <seealso cref="http://en.wikipedia.org/wiki/Binomial_coefficient">Binomial coefficient</seealso>
            MathDisplay.WriteLine("<b>Binomial coefficient</b>");

            // 3. Compute the binomial coefficient: 10 choose 8
            MathDisplay.WriteLine(@"3. Compute the binomial coefficient: 10 choose 8");
            MathDisplay.WriteLine(SpecialFunctions.Binomial(10, 8).ToString("N"));
            MathDisplay.WriteLine();

            // 4. Compute the logarithm of the binomial coefficient: 10 choose 8
            MathDisplay.WriteLine(@"4. Compute the logarithm of the binomial coefficient: 10 choose 8");
            MathDisplay.WriteLine(SpecialFunctions.BinomialLn(10, 8).ToString("N"));
            MathDisplay.WriteLine();

            // <seealso cref="http://en.wikipedia.org/wiki/Multinomial_theorem#Multinomial_coefficients">Multinomial coefficients</seealso>
            MathDisplay.WriteLine("<b>Multinomial coefficient</b>");

            // 5. Compute the multinomial coefficient: 10 choose 2, 3, 5
            MathDisplay.WriteLine(@"5. Compute the multinomial coefficient: 10 choose 2, 3, 5");
            MathDisplay.WriteLine(SpecialFunctions.Multinomial(10, new[] { 2, 3, 5 }).ToString("N"));
            MathDisplay.WriteLine();


            // <seealso cref="http://en.wikipedia.org/wiki/Gamma_function">Gamma function</seealso>
            MathDisplay.WriteLine("<b>Gamma function</b>");

            // 1. Compute the Gamma function of 10
            MathDisplay.WriteLine(@"1. Compute the Gamma function of 10");
            MathDisplay.WriteLine(SpecialFunctions.Gamma(10).ToString("N"));
            MathDisplay.WriteLine();

            // 2. Compute the logarithm of the Gamma function of 10
            MathDisplay.WriteLine(@"2. Compute the logarithm of the Gamma function of 10");
            MathDisplay.WriteLine(SpecialFunctions.GammaLn(10).ToString("N"));
            MathDisplay.WriteLine();

            // 3. Compute the lower incomplete gamma(a, x) function at a = 10, x = 14
            MathDisplay.WriteLine(@"3. Compute the lower incomplete gamma(a, x) function at a = 10, x = 14");
            MathDisplay.WriteLine(SpecialFunctions.GammaLowerIncomplete(10, 14).ToString("N"));
            MathDisplay.WriteLine();

            // 4. Compute the lower incomplete gamma(a, x) function at a = 10, x = 100
            MathDisplay.WriteLine(@"4. Compute the lower incomplete gamma(a, x) function at a = 10, x = 100");
            MathDisplay.WriteLine(SpecialFunctions.GammaLowerIncomplete(10, 100).ToString("N"));
            MathDisplay.WriteLine();

            // 5. Compute the upper incomplete gamma(a, x) function at a = 10, x = 0
            MathDisplay.WriteLine(@"5. Compute the upper incomplete gamma(a, x) function at a = 10, x = 0");
            MathDisplay.WriteLine(SpecialFunctions.GammaUpperIncomplete(10, 0).ToString("N"));
            MathDisplay.WriteLine();

            // 6. Compute the upper incomplete gamma(a, x) function at a = 10, x = 10
            MathDisplay.WriteLine(@"6. Compute the upper incomplete gamma(a, x) function at a = 10, x = 100");
            MathDisplay.WriteLine(SpecialFunctions.GammaLowerIncomplete(10, 10).ToString("N"));
            MathDisplay.WriteLine();

            // 7. Compute the lower regularized gamma(a, x) function at a = 10, x = 14
            MathDisplay.WriteLine(@"7. Compute the lower regularized gamma(a, x) function at a = 10, x = 14");
            MathDisplay.WriteLine(SpecialFunctions.GammaLowerRegularized(10, 14).ToString("N"));
            MathDisplay.WriteLine();

            // 8. Compute the lower regularized gamma(a, x) function at a = 10, x = 100
            MathDisplay.WriteLine(@"8. Compute the lower regularized gamma(a, x) function at a = 10, x = 100");
            MathDisplay.WriteLine(SpecialFunctions.GammaLowerRegularized(10, 100).ToString("N"));
            MathDisplay.WriteLine();

            // 9. Compute the upper regularized gamma(a, x) function at a = 10, x = 0
            MathDisplay.WriteLine(@"9. Compute the upper regularized gamma(a, x) function at a = 10, x = 0");
            MathDisplay.WriteLine(SpecialFunctions.GammaUpperRegularized(10, 0).ToString("N"));
            MathDisplay.WriteLine();

            // 10. Compute the upper regularized gamma(a, x) function at a = 10, x = 10
            MathDisplay.WriteLine(@"10. Compute the upper regularized gamma(a, x) function at a = 10, x = 100");
            MathDisplay.WriteLine(SpecialFunctions.GammaUpperRegularized(10, 10).ToString("N"));
            MathDisplay.WriteLine();

            MathDisplay.WriteLine("<b>Numerical stability</b>");

            // 1. Compute numerically stable exponential of 10 minus one
            MathDisplay.WriteLine(@"1. Compute numerically stable exponential of 4.2876 minus one");
            MathDisplay.WriteLine(SpecialFunctions.ExponentialMinusOne(4.2876).ToString());
            MathDisplay.WriteLine();

            // 2. Compute regular System.Math exponential of 15.28 minus one
            MathDisplay.WriteLine(@"2. Compute regular System.Math exponential of 4.2876 minus one ");
            MathDisplay.WriteLine((Math.Exp(4.2876) - 1).ToString());
            MathDisplay.WriteLine();

            // 3. Compute numerically stable hypotenuse of a right angle triangle with a = 5, b = 3
            MathDisplay.WriteLine(@"3. Compute numerically stable hypotenuse of a right angle triangle with a = 5, b = 3");
            MathDisplay.WriteLine(SpecialFunctions.Hypotenuse(5, 3).ToString());
            MathDisplay.WriteLine();
        }