Added result_class parameter to tab_double and updated all callers. Removed tab_fixed
[pspp] / src / language / stats / ks-one-sample.c
index aba2cbdef4cb5d0db99ccdc1bf5516e76000c3a4..d571693cd8cce5da80e6cfcd1044e6e8477024c9 100644 (file)
@@ -130,9 +130,10 @@ static void show_results (const struct ks *, const struct ks_one_sample_test *,
 
 void
 ks_one_sample_execute (const struct dataset *ds,
-                  struct casereader *input,
-                   enum mv_class exclude,
-                  const struct npar_test *test)
+                      struct casereader *input,
+                      enum mv_class exclude,
+                      const struct npar_test *test,
+                      bool x UNUSED, double y UNUSED)
 {
   const struct dictionary *dict = dataset_dict (ds);
   const struct ks_one_sample_test *kst = UP_CAST (test, const struct ks_one_sample_test, parent.parent);
@@ -142,8 +143,9 @@ ks_one_sample_execute (const struct dataset *ds,
   const struct fmt_spec *wfmt = wvar ? var_get_print_format (wvar) : & F_8_0;
   bool warn = true;
   int v;
+  struct casereader *r = casereader_clone (input);
 
-  struct ks *ks = xcalloc (sizeof *ks, ost->n_vars);
+  struct ks *ks = xcalloc (ost->n_vars, sizeof *ks);
 
   for (v = 0; v < ost->n_vars; ++v)
     {
@@ -156,8 +158,6 @@ ks_one_sample_execute (const struct dataset *ds,
       ks[v].ssq = 0;
     }
 
-  struct casereader *r = casereader_clone (input);
-
   for (; (c = casereader_read (r)) != NULL; case_unref (c))
     {
       const double weight = dict_get_case_weight (dict, c, &warn);
@@ -182,6 +182,10 @@ ks_one_sample_execute (const struct dataset *ds,
 
   for (v = 0; v < ost->n_vars; ++v)
     {
+      const struct variable *var = ost->vars[v];
+      double cc = 0;
+      double prev_empirical = 0;
+
       switch (kst->dist)
        {
        case KS_UNIFORM:
@@ -218,9 +222,6 @@ ks_one_sample_execute (const struct dataset *ds,
          NOT_REACHED ();
        }
 
-      const struct variable *var = ost->vars[v];
-      double cc = 0;
-      double prev_empirical = 0;
       r = sort_execute_1var (casereader_clone (input), var);
       for (; (c = casereader_read (r)) != NULL; case_unref (c))
        {
@@ -275,7 +276,7 @@ show_results (const struct ks *ks,
   const int nc = kst->parent.n_vars + column_headers;
   const int nr = 8 + row_headers;
   struct tab_table *table = tab_create (nc, nr);
-
+  tab_set_format (table, RC_WEIGHT, wfmt);
   tab_headers (table, row_headers, 0, column_headers, 0);
 
   tab_title (table, _("One-Sample Kolmogorov-Smirnov Test"));
@@ -343,21 +344,21 @@ show_results (const struct ks *ks,
       switch (kst->dist)
        {
        case KS_UNIFORM:
-         tab_double (table, col, 1, 0, ks[i].obs_cc, wfmt);
-         tab_double (table, col, 2, 0, ks[i].test_min, NULL);
-         tab_double (table, col, 3, 0, ks[i].test_max, NULL);
+         tab_double (table, col, 1, 0, ks[i].obs_cc, NULL, RC_WEIGHT);
+         tab_double (table, col, 2, 0, ks[i].test_min, NULL, RC_OTHER);
+         tab_double (table, col, 3, 0, ks[i].test_max, NULL, RC_OTHER);
          break;
 
        case KS_NORMAL:
-         tab_double (table, col, 1, 0, ks[i].obs_cc, wfmt);
-         tab_double (table, col, 2, 0, ks[i].mu, NULL);
-         tab_double (table, col, 3, 0, ks[i].sigma, NULL);
+         tab_double (table, col, 1, 0, ks[i].obs_cc, NULL, RC_WEIGHT);
+         tab_double (table, col, 2, 0, ks[i].mu, NULL, RC_OTHER);
+         tab_double (table, col, 3, 0, ks[i].sigma, NULL, RC_OTHER);
          break;
 
        case KS_POISSON:
        case KS_EXPONENTIAL:
-         tab_double (table, col, 1, 0, ks[i].obs_cc, wfmt);
-         tab_double (table, col, 2, 0, ks[i].mu, NULL);
+         tab_double (table, col, 1, 0, ks[i].obs_cc, NULL, RC_WEIGHT);
+         tab_double (table, col, 2, 0, ks[i].mu, NULL, RC_OTHER);
          break;
 
        default:
@@ -369,13 +370,13 @@ show_results (const struct ks *ks,
 
       z = sqrt (ks[i].obs_cc) * abs;
 
-      tab_double (table, col, 5, 0, ks[i].diff_pos, NULL);
-      tab_double (table, col, 6, 0, ks[i].diff_neg, NULL);
+      tab_double (table, col, 5, 0, ks[i].diff_pos, NULL, RC_OTHER);
+      tab_double (table, col, 6, 0, ks[i].diff_neg, NULL, RC_OTHER);
 
-      tab_double (table, col, 4, 0, abs, NULL);
+      tab_double (table, col, 4, 0, abs, NULL, RC_OTHER);
 
-      tab_double (table, col, 7, 0, z, NULL);
-      tab_double (table, col, 8, 0, ks_asymp_sig (z), NULL);
+      tab_double (table, col, 7, 0, z, NULL, RC_OTHER);
+      tab_double (table, col, 8, 0, ks_asymp_sig (z), NULL, RC_PVALUE);
     }