[gnumeric] sstest: fix mean test for hypergeometric random generator.



commit 422f5e4f711ed78c274e20b62159e4d0bb12083b
Author: Morten Welinder <terra gnome org>
Date:   Mon Mar 30 11:41:26 2015 -0400

    sstest: fix mean test for hypergeometric random generator.

 ChangeLog    |    3 +++
 src/sstest.c |   32 ++++++++++++++++----------------
 2 files changed, 19 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 00634e7..538d688 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-03-30  Morten Welinder  <terra gnome org>
 
+       * src/sstest.c (test_random_randhyperg): Take var=0 case into
+       account when checking mean.
+
        * src/sheet-object-graph.c (sheet_object_graph_new): Allow NULL
        graph here.
 
diff --git a/src/sstest.c b/src/sstest.c
index b12eea4..a24d8c7 100644
--- a/src/sstest.c
+++ b/src/sstest.c
@@ -830,7 +830,7 @@ test_random_randuniform (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -955,7 +955,7 @@ test_random_randdiscrete (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1143,7 +1143,7 @@ test_random_randexp (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1219,7 +1219,7 @@ test_random_randgamma (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1297,7 +1297,7 @@ test_random_randbeta (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1372,7 +1372,7 @@ test_random_randtdist (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (gnm_finite (var_target) && !(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (gnm_finite (var_target) && !(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1451,7 +1451,7 @@ test_random_randfdist (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (gnm_finite (var_target) && !(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (gnm_finite (var_target) && !(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1526,7 +1526,7 @@ test_random_randchisq (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (gnm_finite (var_target) && !(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (gnm_finite (var_target) && !(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1606,7 +1606,7 @@ test_random_randcauchy (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (gnm_finite (var_target) && !(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (gnm_finite (var_target) && !(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1682,7 +1682,7 @@ test_random_randbinom (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1761,7 +1761,7 @@ test_random_randnegbinom (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1844,7 +1844,7 @@ test_random_randhyperg (int N)
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
        if (gnm_finite (var_target) &&
-           !(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+           !(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1922,7 +1922,7 @@ test_random_randbetween (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -1991,7 +1991,7 @@ test_random_randpoisson (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -2071,7 +2071,7 @@ test_random_randgeom (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }
@@ -2157,7 +2157,7 @@ test_random_randlog (int N)
 
        T = mean_target;
        g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
-       if (!(gnm_abs (mean - T) < 3 * gnm_sqrt (var_target / N))) {
+       if (!(gnm_abs (mean - T) <= 3 * gnm_sqrt (var_target / N))) {
                g_printerr ("Mean failure.\n");
                ok = FALSE;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]