public void testGamma()
 {
     for (int i = 0; i < GAMMA_REF.GetLength(0); i++)
     {
         double x        = GAMMA_REF[i, 0];
         double expected = GAMMA_REF[i, 1];
         double actual   = Gamma.gamma(x);
         double absX     = Math.Abs(x);
         int    ulps;
         if (absX <= 8.0)
         {
             ulps = 3;
         }
         else if (absX <= 20.0)
         {
             ulps = 5;
         }
         else if (absX <= 30.0)
         {
             ulps = 50;
         }
         else if (absX <= 50.0)
         {
             ulps = 180;
         }
         else
         {
             ulps = 500;
         }
         double tol = ulps * BetaTest.ulp(expected);
         Assert.AreEqual(expected, actual, tol, Convert.ToString(x));
     }
 }
        public void testLogGamma1p()
        {
            int ulps = 3;

            for (int i = 0; i < LOG_GAMMA1P_REF.GetLength(0); i++)
            {
                double x        = LOG_GAMMA1P_REF[i, 0];
                double expected = LOG_GAMMA1P_REF[i, 1];
                double actual   = Gamma.logGamma1p(x);
                double tol      = ulps * BetaTest.ulp(expected);
                Assert.AreEqual(expected, actual, tol, Convert.ToString(x));
            }
        }
        public void testInvGamma1pm1()
        {
            int ulps = 3;

            for (int i = 0; i < INV_GAMMA1P_M1_REF.GetLength(0); i++)
            {
                double x        = INV_GAMMA1P_M1_REF[i, 0];
                double expected = INV_GAMMA1P_M1_REF[i, 1];
                double actual   = Gamma.invGamma1pm1(x);
                double tol      = ulps * BetaTest.ulp(expected);
                Assert.AreEqual(expected, actual, tol, Convert.ToString(x));
            }
        }
Example #4
0
        public void testLogBeta()
        {
            int ulps = 3;

            for (int i = 0; i < LOG_BETA_REF.GetLength(0); i++)
            {
                double a        = LOG_BETA_REF[i, 0];
                double b        = LOG_BETA_REF[i, 1];
                double expected = LOG_BETA_REF[i, 2];
                double actual   = Beta.logBeta(a, b);
                double tol      = ulps * BetaTest.ulp(expected);
                var    builder  = new System.Text.StringBuilder();
                builder.Append(a).Append(", ").Append(b);
                Assert.AreEqual(expected, actual, tol, builder.ToString());
            }
        }
Example #5
0
        public void testSumDeltaMinusDeltaSum()
        {
            int ulps = 3;

            for (int i = 0; i < SUM_DELTA_MINUS_DELTA_SUM_REF.GetLength(0); i++)
            {
                double a        = SUM_DELTA_MINUS_DELTA_SUM_REF[i, 0];
                double b        = SUM_DELTA_MINUS_DELTA_SUM_REF[i, 1];
                double expected = SUM_DELTA_MINUS_DELTA_SUM_REF[i, 2];
                double actual   = sumDeltaMinusDeltaSum(a, b);
                double tol      = ulps * BetaTest.ulp(expected);
                var    builder  = new System.Text.StringBuilder();
                builder.Append(a).Append(", ").Append(b);
                Assert.AreEqual(expected, actual, tol, builder.ToString());
            }
        }
Example #6
0
        public void testLogGammaMinusLogGammaSum()
        {
            int ulps = 4;

            for (int i = 0; i < LOG_GAMMA_MINUS_LOG_GAMMA_SUM_REF.GetLength(0); i++)
            {
                double a        = LOG_GAMMA_MINUS_LOG_GAMMA_SUM_REF[i, 0];
                double b        = LOG_GAMMA_MINUS_LOG_GAMMA_SUM_REF[i, 1];
                double expected = LOG_GAMMA_MINUS_LOG_GAMMA_SUM_REF[i, 2];
                double actual   = logGammaMinusLogGammaSum(a, b);
                double tol      = ulps * BetaTest.ulp(expected);
                var    builder  = new System.Text.StringBuilder();
                builder.Append(a).Append(", ").Append(b);
                Assert.AreEqual(expected, actual, tol, builder.ToString());
            }
        }
        public void testLogGamma()
        {
            int ulps = 3;

            for (int i = 0; i < LOG_GAMMA_REF.GetLength(0); i++)
            {
                double x        = LOG_GAMMA_REF[i, 0];
                double expected = LOG_GAMMA_REF[i, 1];
                double actual   = Gamma.logGamma(x);
                double tol;
                if (expected == 0.0)
                {
                    tol = 1E-15;
                }
                else
                {
                    tol = ulps * BetaTest.ulp(expected);
                }
                Assert.AreEqual(expected, actual, tol, x.ToString());
            }
        }