[gnumeric] Tests: improve random numbers tests' debugability.



commit 9824b574f6e2301b4d1ea49e55aa6c0a916e6778
Author: Morten Welinder <terra gnome org>
Date:   Wed Jan 13 13:33:45 2016 -0500

    Tests: improve random numbers tests' debugability.

 ChangeLog    |    3 +++
 src/sstest.c |   14 ++++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2147006..d7782e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2016-01-13  Morten Welinder  <terra gnome org>
 
+       * src/sstest.c (test_random_randsnorm)
+       (test_random_randbernoulli): Print expected stats.
+
        * src/xml-sax-read.c (xml_sax_filter_condition): Ensure o0 and op1
        are sane.  Fixes #760544.
 
diff --git a/src/sstest.c b/src/sstest.c
index 835937f..5fb27bd 100644
--- a/src/sstest.c
+++ b/src/sstest.c
@@ -916,21 +916,28 @@ test_random_randbernoulli (int N)
        }
 
        T = p;
+       g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
        if (gnm_abs (mean - p) > 0.01) {
                g_printerr ("Mean failure [%.10" GNM_FORMAT_g "]\n", T);
                ok = FALSE;
        }
+
        T = p * (1 - p);
+       g_printerr ("Expected var: %.10" GNM_FORMAT_g "\n", T);
        if (gnm_abs (var - T) > 0.01) {
                g_printerr ("Var failure [%.10" GNM_FORMAT_g "]\n", T);
                ok = FALSE;
        }
+
        T = (q - p) / gnm_sqrt (p * q);
+       g_printerr ("Expected skew: %.10" GNM_FORMAT_g "\n", T);
        if (gnm_abs (skew - T) > 0.05) {
                g_printerr ("Skew failure [%.10" GNM_FORMAT_g "]\n", T);
                ok = FALSE;
        }
+
        T = (1 - 6 * p * q) / (p * q);
+       g_printerr ("Expected kurt: %.10" GNM_FORMAT_g "\n", T);
        if (gnm_abs (kurt - T) > 0.10) {
                g_printerr ("Kurt failure [%.10" GNM_FORMAT_g "]\n", T);
                ok = FALSE;
@@ -1107,22 +1114,29 @@ test_random_randsnorm (int N)
        }
 
        T = mean_target;
+       g_printerr ("Expected mean: %.10" GNM_FORMAT_g "\n", T);
        if (gnm_abs (mean - T) > 0.01) {
                g_printerr ("Mean failure [%.10" GNM_FORMAT_g "]\n", T);
                ok = FALSE;
        }
+
        T = var_target;
+       g_printerr ("Expected var: %.10" GNM_FORMAT_g "\n", T);
        if (gnm_abs (var - T) > 0.01) {
                g_printerr ("Var failure [%.10" GNM_FORMAT_g "]\n", T);
                ok = FALSE;
        }
+
        T = mean_target/gnm_sqrt(var_target);
        T = T*T*T*(4-M_PIgnum)/2;
+       g_printerr ("Expected skew: %.10" GNM_FORMAT_g "\n", T);
        if (gnm_abs (skew - T) > 0.05) {
                g_printerr ("Skew failure [%.10" GNM_FORMAT_g "]\n", T);
                ok = FALSE;
        }
+
        T = 2*(M_PIgnum - 3)*mean_target*mean_target*mean_target*mean_target/(var_target*var_target);
+       g_printerr ("Expected kurt: %.10" GNM_FORMAT_g "\n", T);
        if (gnm_abs (kurt - T) > 0.15) {
                g_printerr ("Kurt failure [%.10" GNM_FORMAT_g "]\n", T);
                ok = FALSE;


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